relay

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2022 License: AGPL-3.0 Imports: 15 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 Auctioneer added in v0.3.4

type Auctioneer interface {
	AddBlock(block *structs.CompleteBlockstruct) bool
	MaxProfitBlock(slot structs.Slot) (*structs.CompleteBlockstruct, bool)
}

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(l log.Logger, verifySize, storeSize uint) *ProcessManager

func (*ProcessManager) AttachMetrics

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

func (*ProcessManager) Close added in v0.3.3

func (pm *ProcessManager) Close(ctx context.Context)

func (*ProcessManager) Get

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

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 (pm *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) SendStore added in v0.3.3

func (rm *ProcessManager) SendStore(request StoreReq)

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
	StoreTiming  prometheus.Histogram
	StoreSize    prometheus.Histogram

	MapSize prometheus.Gauge

	StoreErrorRate prometheus.Counter

	RunningWorkers *prometheus.GaugeVec
}

type RegistrationManager

type RegistrationManager interface {
	//GetStoreChan() chan StoreReq
	GetVerifyChan(buffer uint) chan VerifyReq

	SendStore(sReq StoreReq)
	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, a Auctioneer) *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) (err 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) 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

	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 {
	Items []StoreReqItem
}

type StoreReqItem added in v0.3.3

type StoreReqItem struct {
	RawPayload json.RawMessage
	Time       uint64
	Pubkey     types.PublicKey
}

StoreReqItem is similar to VerifyReq jsut for storing payloads

type StoreResp added in v0.3.3

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

func NewRespC added in v0.3.3

func NewRespC(numAll int) (s *StoreResp)

func (*StoreResp) Close added in v0.3.3

func (s *StoreResp) Close(id int, err error)

func (*StoreResp) Done added in v0.3.3

func (s *StoreResp) Done() chan error

func (*StoreResp) Error added in v0.3.3

func (s *StoreResp) Error() (err error)

func (*StoreResp) IsClosed added in v0.3.3

func (s *StoreResp) IsClosed() bool

func (*StoreResp) Send added in v0.3.3

func (s *StoreResp) Send(r Resp)

func (*StoreResp) SuccessfullIndexes added in v0.3.3

func (s *StoreResp) SuccessfullIndexes() []int64

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 *StoreResp
}

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