server

package
v0.0.0-...-9f84b30 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: Apache-2.0 Imports: 86 Imported by: 0

Documentation

Overview

simple type aliases that make readability, imports, and auto complete easier

Request forward for the internal cometbft rpc. Debug info and to be turned off by default.

implementation of the grpc service definition found in the audius protocol.proto spec

contains all the routes that core serves

The mempool (memory pool) stores and broadcasts transactions that are prepared to be included in a block. There is no guarantee that when a transaction makes it into the mempool that it will be included in a block.

Peers that core is aware of and uses. This is different than the lower level p2p list that cometbft manages. This is where we store sdk clients for other validators for the purposes of forwarding transactions, querying health checks, and anything else.

Keeps the validators updated in cometbft and core up to date with what is present on the ethereum node registry.

Index

Constants

View Source
const (
	ProcessStateABCI           = "abci"
	ProcessStateRegistryBridge = "registryBridge"
	ProcessStateEchoServer     = "echoServer"
	ProcessStateSyncTasks      = "syncTasks"
	ProcessStatePeerManager    = "peerManager"
	ProcessStateDataCompanion  = "dataCompanion"
	ProcessStateCache          = "cache"
	ProcessStateLogSync        = "logSync"
	ProcessStateStateSync      = "stateSync"
	ProcessStateMempoolCache   = "mempoolCache"

	NodeInfoKey      = "nodeInfo"
	PeersKey         = "peers"
	ChainInfoKey     = "chainInfo"
	SyncInfoKey      = "syncInfo"
	PruningInfoKey   = "pruningInfo"
	ResourceInfoKey  = "resourceInfo"
	ValidatorInfoKey = "validatorInfo"
	MempoolInfoKey   = "mempoolInfo"
	SnapshotInfoKey  = "snapshotInfo"
)
View Source
const BlockNumPubsubTopic = "block-num-topic"

Variables

View Source
var (
	// ERN top level errors
	ErrERNMessageValidation   = errors.New("ERN message validation failed")
	ErrERNMessageFinalization = errors.New("ERN message finalization failed")

	// Create ERN message validation errors
	ErrERNAddressNotEmpty   = errors.New("ERN address is not empty")
	ErrERNFromAddressEmpty  = errors.New("ERN from address is empty")
	ErrERNToAddressNotEmpty = errors.New("ERN to address is not empty")
	ErrERNNonceNotOne       = errors.New("ERN nonce is not one")

	// Update ERN message validation errors
	ErrERNAddressEmpty   = errors.New("ERN address is empty")
	ErrERNToAddressEmpty = errors.New("ERN to address is empty")
	ErrERNAddressNotTo   = errors.New("ERN address is not the target of the message")
	ErrERNNonceNotNext   = errors.New("ERN nonce is not the next nonce")
)
View Source
var (
	TrackPlaysProtoName     string
	ManageEntitiesProtoName string
	SlaRollupProtoName      string
	SlaNodeReportProtoName  string
)
View Source
var (
	// MEAD top level errors
	ErrMEADMessageValidation   = errors.New("MEAD message validation failed")
	ErrMEADMessageFinalization = errors.New("MEAD message finalization failed")

	// Create MEAD message validation errors
	ErrMEADAddressNotEmpty   = errors.New("MEAD address is not empty")
	ErrMEADFromAddressEmpty  = errors.New("MEAD from address is empty")
	ErrMEADToAddressNotEmpty = errors.New("MEAD to address is not empty")
	ErrMEADNonceNotOne       = errors.New("MEAD nonce is not one")

	// Update MEAD message validation errors
	ErrMEADAddressEmpty                     = errors.New("MEAD address is empty")
	ErrMEADToAddressEmpty                   = errors.New("MEAD to address is empty")
	ErrMEADAddressNotTo                     = errors.New("MEAD address is not the target of the message")
	ErrMEADNonceNotNext                     = errors.New("MEAD nonce is not the next nonce")
	ErrMEADResourceAndReleaseAddressesEmpty = errors.New("MEAD resource and release addresses are empty")
)
View Source
var (
	// PIE top level errors
	ErrPIEMessageValidation   = errors.New("PIE message validation failed")
	ErrPIEMessageFinalization = errors.New("PIE message finalization failed")

	// Create PIE message validation errors
	ErrPIEAddressNotEmpty   = errors.New("PIE address is not empty")
	ErrPIEFromAddressEmpty  = errors.New("PIE from address is empty")
	ErrPIEToAddressNotEmpty = errors.New("PIE to address is not empty")
	ErrPIENonceNotOne       = errors.New("PIE nonce is not one")

	// Update PIE message validation errors
	ErrPIEAddressEmpty   = errors.New("PIE address is empty")
	ErrPIEToAddressEmpty = errors.New("PIE to address is empty")
	ErrPIEAddressNotTo   = errors.New("PIE address is not the target of the message")
	ErrPIENonceNotNext   = errors.New("PIE nonce is not the next nonce")
)
View Source
var (
	ErrRpcStatusNotFound      = errors.New("local rpc status not returned")
	ErrRpcNotSynced           = errors.New("local rpc not synced")
	ErrCreateValidatorClients = errors.New("couldn't create validator clients")
)
View Source
var (
	ErrV2TransactionExpired        = errors.New("transaction expired")
	ErrV2TransactionInvalidChainID = errors.New("invalid chain id")
)
View Source
var (
	ErrFullMempool = errors.New("mempool full")
)

Functions

func CalculateSlashRecommendation

func CalculateSlashRecommendation(startTime, endTime time.Time, totalEndpoints, totalSlas, missedSlas int) int64

Calculate slash recommendation based on SLA performance. Explanation:

200k AUDIO is the minimum stake per endpoint.
We therefore recommend slashing 200k AUDIO for a full year of zero sla performance
from a single endpoint.
$AUDIO to slash = $200k * number of endpoints * (days in selected interval / 365) * (zeroed SLAs / total SLAs)

func GetProtoTypeName

func GetProtoTypeName(msg proto.Message) string

func SignSlashRecommendation

func SignSlashRecommendation(ethKey *ecdsa.PrivateKey, slash *corev1.SlashRecommendation) (string, error)

Types

type ABCIState

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

state that the abci specifically relies on

func NewABCIState

func NewABCIState(initialRetainHeight int64) *ABCIState

type BlockNumPubsub

type BlockNumPubsub = pubsub.Pubsub[int64]

type Cache

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

a simple in memory cache of frequently queried things maybe upgrade to something like bigcache later

func NewCache

func NewCache(config *config.Config) *Cache

func (*Cache) UpdateProcessState

func (c *Cache) UpdateProcessState(processKey string, state v1.GetStatusResponse_ProcessInfo_ProcessState, errorMsg string, metadata string) error

type CometBFTAddress

type CometBFTAddress = string

type CometBFTListener

type CometBFTListener = string

type CometBFTRPC

type CometBFTRPC = rpchttp.HTTP

type CometP2PConnectionString

type CometP2PConnectionString = string

type CoreService

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

func NewCoreService

func NewCoreService() *CoreService

func (*CoreService) ForwardTransaction

ForwardTransaction implements v1connect.CoreServiceHandler.

func (*CoreService) GetBlock

GetBlock implements v1connect.CoreServiceHandler.

func (*CoreService) GetBlocks

GetBlocks implements v1connect.CoreServiceHandler.

func (*CoreService) GetDeregistrationAttestation

GetDeregistrationAttestation implements v1connect.CoreServiceHandler.

func (*CoreService) GetERN

GetERN implements v1connect.CoreServiceHandler.

func (*CoreService) GetHealth

GetHealth implements v1connect.CoreServiceHandler.

func (*CoreService) GetMEAD

GetMEAD implements v1connect.CoreServiceHandler.

func (*CoreService) GetNodeInfo

GetNodeInfo implements v1connect.CoreServiceHandler.

func (*CoreService) GetPIE

GetPIE implements v1connect.CoreServiceHandler.

func (*CoreService) GetRegistrationAttestation

GetRegistrationAttestation implements v1connect.CoreServiceHandler.

func (*CoreService) GetRewardAttestation

GetRewardAttestation implements v1connect.CoreServiceHandler.

func (*CoreService) GetRewards

GetRewards implements v1connect.CoreServiceHandler.

func (*CoreService) GetStatus

GetStatus implements v1connect.CoreServiceHandler.

func (*CoreService) GetStoredSnapshots

GetStoredSnapshots implements v1connect.CoreServiceHandler.

func (*CoreService) GetTransaction

GetTransaction implements v1connect.CoreServiceHandler.

func (*CoreService) Ping

Ping implements v1connect.CoreServiceHandler.

func (*CoreService) SendTransaction

SendTransaction implements v1connect.CoreServiceHandler.

func (*CoreService) SetCore

func (c *CoreService) SetCore(core *Server)

type EthAPI

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

func (*EthAPI) BlockNumber

func (api *EthAPI) BlockNumber(ctx context.Context) (*hexutil.Uint64, error)

eth_blockNumber

func (*EthAPI) ChainId

func (api *EthAPI) ChainId(ctx context.Context) (*hexutil.Big, error)

eth_chainId

func (*EthAPI) GetBlockByNumber

func (api *EthAPI) GetBlockByNumber(ctx context.Context, blockNumber string, fullTx bool) (map[string]any, error)

type EthAddress

type EthAddress = string

type Mempool

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

func NewMempool

func NewMempool(logger *zap.Logger, config *config.Config, db *db.Queries, maxTransactions int) *Mempool

func (*Mempool) GetAll

func (m *Mempool) GetAll() []*MempoolTransaction

func (*Mempool) GetBatch

func (m *Mempool) GetBatch(batchSize int, currentBlock int64) []*MempoolTransaction

gathers a batch of transactions skipping those that have expired

func (*Mempool) MempoolSize

func (m *Mempool) MempoolSize() (int, int)

func (*Mempool) RemoveBatch

func (m *Mempool) RemoveBatch(ids []string)

func (*Mempool) RemoveExpiredTransactions

func (m *Mempool) RemoveExpiredTransactions(blockNum int64)

type MempoolTransaction

type MempoolTransaction struct {
	Deadline int64
	Tx       *v1.SignedTransaction
	Txv2     *v1beta1.Transaction
}

signed tx with mempool related metadata deadline - the block MUST be included in a block prior to the deadline

type Metadata

type Metadata struct {
	Sender  string `json:"sender"`
	ChainID string `json:"chain_id"`
}

type NetAPI

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

func (*NetAPI) Version

func (api *NetAPI) Version(ctx context.Context) (string, error)

net_version

type RegisteredNodeVerboseResponse

type RegisteredNodeVerboseResponse struct {
	Owner               string `json:"owner"`
	Endpoint            string `json:"endpoint"`
	SpID                uint64 `json:"spID"`
	NodeType            string `json:"type"`
	BlockNumber         uint64 `json:"blockNumber"`
	DelegateOwnerWallet string `json:"delegateOwnerWallet"`
	CometAddress        string `json:"cometAddress"`
}

type RegisteredNodesEndpointResponse

type RegisteredNodesEndpointResponse struct {
	RegisteredNodes []string `json:"data"`
}

type RegisteredNodesVerboseResponse

type RegisteredNodesVerboseResponse struct {
	RegisteredNodes []*RegisteredNodeVerboseResponse `json:"data"`
}

type Server

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

func NewServer

func NewServer(lc *lifecycle.Lifecycle, config *config.Config, cconfig *cconfig.Config, logger *zap.Logger, pool *pgxpool.Pool, ethService *eth.EthService, posChannel chan pos.PoSRequest) (*Server, error)

func (*Server) CheckTx

func (*Server) CleanupStateSync

func (s *Server) CleanupStateSync() error

func (*Server) Commit

func (*Server) CompactBlockstoreDB

func (s *Server) CompactBlockstoreDB() error

func (*Server) CompactStateDB

func (s *Server) CompactStateDB() error

func (*Server) CompleteProcess

func (s *Server) CompleteProcess(processKey string) error

func (*Server) ErrorProcess

func (s *Server) ErrorProcess(processKey string, errorMsg string) error

func (*Server) ExtendVote

func (*Server) GetChunkByHeight

func (s *Server) GetChunkByHeight(height int64, chunk int) ([]byte, error)

GetChunkByHeight retrieves a specific chunk for a given block height

func (*Server) GetEcho

func (s *Server) GetEcho() *echo.Echo

func (*Server) GetOfferedSnapshot

func (s *Server) GetOfferedSnapshot() (*v1.Snapshot, error)

func (*Server) Info

func (*Server) InitChain

func (*Server) IsNodeRegisteredOnEthereum

func (s *Server) IsNodeRegisteredOnEthereum(ctx context.Context, endpoint, delegateWallet string, ethBlock int64) (bool, error)

func (*Server) ListSnapshots

func (*Server) PrepareProposal

func (*Server) ProcessProposal

func (*Server) Query

func (*Server) ReassemblePgDump

func (s *Server) ReassemblePgDump(height int64) error

ReassemblePgDump reconstructs and decompresses a binary pg_dump file from multiple gzipped chunks

func (*Server) RegisterSelf

func (s *Server) RegisterSelf() error

checks mainnet eth for itself, if registered and not already in the comet state will register itself on comet

func (*Server) RestoreDatabase

func (s *Server) RestoreDatabase(height int64) error

RestoreDatabase restores the PostgreSQL database using the reassembled pg_dump binary file

func (*Server) RunningProcess

func (s *Server) RunningProcess(processKey string) error

func (*Server) RunningProcessWithMetadata

func (s *Server) RunningProcessWithMetadata(processKey string, metadata string) error

func (*Server) ShouldPurgeValidatorForUnderperformance

func (s *Server) ShouldPurgeValidatorForUnderperformance(ctx context.Context, validatorAddress string) (bool, error)

func (*Server) Shutdown

func (s *Server) Shutdown() error

func (*Server) SleepingProcess

func (s *Server) SleepingProcess(processKey string) error

func (*Server) SleepingProcessWithMetadata

func (s *Server) SleepingProcessWithMetadata(processKey string, metadata string) error

func (*Server) Start

func (s *Server) Start() error

func (*Server) StartProcess

func (s *Server) StartProcess(processKey string) error

func (*Server) StoreChunkForReconstruction

func (s *Server) StoreChunkForReconstruction(height int64, chunkIndex int, chunkData []byte) error

StoreChunkForReconstruction stores a single chunk in a temporary directory for later reconstruction

func (*Server) StoreOfferedSnapshot

func (s *Server) StoreOfferedSnapshot(snapshot *v1.Snapshot) error

type TransactionHashPubsub

type TransactionHashPubsub = pubsub.Pubsub[struct{}]

subscribes by tx hash, pubsub completes once tx is committed

type Web3API

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

func (*Web3API) ClientVersion

func (api *Web3API) ClientVersion(ctx context.Context) (string, error)

Stub: web3_clientVersion

Jump to

Keyboard shortcuts

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