relay

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseQueueSubmit = iota
	ResponseQueueRegister
	ResponseQueueOther
)
View Source
const (
	ResponseTypeVerify = iota
	ResponseTypeOthers
	ResponseTypeStored
)
View Source
const BLST_SUCCESS = 0x0

Variables

View Source
var (
	ErrNoPayloadFound        = errors.New("no payload found")
	ErrMissingRequest        = errors.New("req is nil")
	ErrMissingSecretKey      = errors.New("secret key is nil")
	UnregisteredValidatorMsg = "unregistered validator"
)

Functions

func SubmissionToKey

func SubmissionToKey(submission *types.BuilderSubmitBlockRequest) structs.PayloadKey

func SubmitBlockRequestToBlockBidAndTrace

func SubmitBlockRequestToBlockBidAndTrace(signedBuilderBid *types.SignedBuilderBid, submitBlockRequest *types.BuilderSubmitBlockRequest) structs.BlockBidAndTrace

func SubmitBlockRequestToSignedBuilderBid

func SubmitBlockRequestToSignedBuilderBid(req *types.BuilderSubmitBlockRequest, sk *bls.SecretKey, pubkey *types.PublicKey, domain types.Domain) (*types.SignedBuilderBid, error)

***** Relay Domain ***** SubmitBlockRequestToSignedBuilderBid converts a builders block submission to a bid compatible with mev-boost

func VerifySignature

func VerifySignature(obj types.HashTreeRoot, d types.Domain, pkBytes, sigBytes []byte) (bool, error)

func VerifySignatureBytes

func VerifySignatureBytes(msg [32]byte, sigBytes, pkBytes []byte) (ok bool, err error)

Types

type FlowControl

type FlowControl struct {
	RespCh chan Resp

	FailureCh chan struct{}
	ExitCh    chan error
	// contains filtered or unexported fields
}

func NewFlowControl

func NewFlowControl(respCh chan Resp, numElements int) (fc *FlowControl)

NewFlowControl takes responseChannel that should be big enougth to store *all* the responses So the external channel should be passed here from pool However, if it's not (nil respCh) the per flow channel is created to handle numElements*3

func (*FlowControl) Close

func (fc *FlowControl) Close()

func (*FlowControl) Exit

func (fc *FlowControl) Exit(err error)

func (*FlowControl) Fail

func (fc *FlowControl) Fail()

func (*FlowControl) SentVerificationInc

func (fc *FlowControl) SentVerificationInc()

func (*FlowControl) SentVerifications

func (fc *FlowControl) SentVerifications() uint32

type ProcessManager

type ProcessManager struct {
	LastRegTime map[string]uint64 // [pubkey]timestamp

	VerifySubmitBlockCh       chan VerifyReq
	VerifyRegisterValidatorCh chan VerifyReq
	VerifyOtherCh             chan VerifyReq

	StoreCh chan StoreReq
	// contains filtered or unexported fields
}

func NewProcessManager

func NewProcessManager(verifySize, storeSize uint) *ProcessManager

func (*ProcessManager) AttachMetrics

func (rm *ProcessManager) AttachMetrics(m *metrics.Metrics)

func (*ProcessManager) Get

func (rm *ProcessManager) Get(k string) (value uint64, ok bool)

func (*ProcessManager) GetStoreChan

func (rm *ProcessManager) GetStoreChan() chan StoreReq

func (*ProcessManager) GetVerifyChan

func (rm *ProcessManager) GetVerifyChan(stack uint) chan VerifyReq

func (*ProcessManager) LoadAll

func (rm *ProcessManager) LoadAll(m map[string]uint64)

func (*ProcessManager) ParallelStore

func (rm *ProcessManager) ParallelStore(datas Datastore, ttl time.Duration)

func (*ProcessManager) RunCleanup

func (rm *ProcessManager) RunCleanup(checkinterval uint64, cleanupInterval time.Duration)

func (*ProcessManager) RunStore

func (rm *ProcessManager) RunStore(store Datastore, ttl time.Duration, num uint)

func (*ProcessManager) RunVerify

func (rm *ProcessManager) RunVerify(num uint)

func (*ProcessManager) Set

func (rm *ProcessManager) Set(k string, value uint64)

func (*ProcessManager) VerifyChan

func (rm *ProcessManager) VerifyChan() chan VerifyReq

func (*ProcessManager) VerifyParallel

func (rm *ProcessManager) VerifyParallel()

type ProcessManagerMetrics

type ProcessManagerMetrics struct {
	VerifyTiming *prometheus.HistogramVec

	MapSize prometheus.Gauge

	RunningWorkers *prometheus.GaugeVec
}

type RegistrationManager

type RegistrationManager interface {
	GetStoreChan() chan StoreReq
	GetVerifyChan(buffer uint) chan VerifyReq
	Set(k string, value uint64)
	Get(k string) (value uint64, ok bool)
}

type Relay

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

func NewRelay

func NewRelay(l log.Logger, config RelayConfig, beaconState State, d Datastore, regMngr RegistrationManager) *Relay

NewRelay relay service

func (*Relay) AttachMetrics

func (r *Relay) AttachMetrics(m *metrics.Metrics)

func (*Relay) GetHeader

func (rs *Relay) GetHeader(ctx context.Context, request structs.HeaderRequest) (*types.GetHeaderResponse, error)

GetHeader is called by a block proposer communicating through mev-boost and returns a bid along with an execution payload header

func (*Relay) GetPayload

func (rs *Relay) GetPayload(ctx context.Context, payloadRequest *types.SignedBlindedBeaconBlock) (*types.GetPayloadResponse, error)

GetPayload is called by a block proposer communicating through mev-boost and reveals execution payload of given signed beacon block if stored

func (*Relay) GetValidators

GetValidators returns a list of registered block proposers in current and next epoch

func (*Relay) RegisterValidator

func (rs *Relay) RegisterValidator(ctx context.Context, payload []structs.SignedValidatorRegistration) error

***** Builder Domain ***** RegisterValidator is called is called by validators communicating through mev-boost who would like to receive a block from us when their slot is scheduled

func (*Relay) RegisterValidatorSingular

func (rs *Relay) RegisterValidatorSingular(ctx context.Context, payload structs.SignedValidatorRegistration) error

func (*Relay) SubmitBlock

func (rs *Relay) SubmitBlock(ctx context.Context, submitBlockRequest *types.BuilderSubmitBlockRequest) error

SubmitBlock Accepts block from trusted builder and stores

type RelayConfig

type RelayConfig struct {
	BuilderSigningDomain  types.Domain
	ProposerSigningDomain types.Domain
	PubKey                types.PublicKey
	SecretKey             *bls.SecretKey

	// RegisterValidatorMaxNum is needed to set size of the buffer queue
	// describing the queue of results before it would be processed by registerSync
	RegisterValidatorMaxNum uint64
	TTL                     time.Duration
}

type RelayMetrics

type RelayMetrics struct {
	Timing *prometheus.HistogramVec
}

type Resp

type Resp struct {
	ID     int
	Type   int8
	Commit bool
	Err    error
}

Resp respone structure - potential candidate for structure pool as it's almost constant size

type State

type State interface {
	Beacon() *structs.BeaconState
}

type StoreReq

type StoreReq struct {
	RawPayload json.RawMessage
	Pubkey     types.PublicKey
	ID         int
	Response   chan Resp
}

StoreReq is similar to VerifyReq jsut for storing payloads

type TimestampRegistry

type TimestampRegistry interface {
	Get(pubkey string) (timestamp uint64, ok bool)
}

type VerifyReq

type VerifyReq struct {
	Signature [96]byte
	Pubkey    [48]byte
	Msg       [32]byte
	// Unique identifier of payload
	// if needed to be passed back in response
	ID       int
	Response chan Resp
}

VerifyReq is a request structure used in communication between api calls and fixed set of worker goroutines it's using return channel pattern, meaning that after sent the sender locks on that channel to get the response

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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