guardianproverhealthcheck

package
v0.3.1-0...-ee1233d Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 15 Imported by: 0

README

Golang GuardianProverHealthCheck

Guardian Prover Health Check Service

A service that watches the guardian provers and pings them for uptime availability metrics.

Build the source

Building the taiko-client binary requires a Go compiler. Once installed, run:

make build

Configuration

Run migrations: cd migrations goose mysql "user:pass@/dbname?parseTime=true" up

To run the health check service: ENV_FILE=.env go run cmd/main.go healthchecker

To run the stats generator: ENV_FILE=.generator.env go run cmd/main.go generator

Usage

Review all available sub-commands:

bin/guardian-prover-health-check --help

Review each sub-command's command line flags:

bin/guardian-prover-health-check <sub-command> --help

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDB = errors.Validation.NewWithKeyAndDetail("ERR_NO_DB", "DB is required")
)
View Source
var (
	EventsProcessed = promauto.NewCounter(prometheus.CounterOpts{
		Name: "events_processed_ops_total",
		Help: "The total number of processed events",
	})
)

Functions

This section is empty.

Types

type DB

type DB interface {
	DB() (*sql.DB, error)
	GormDB() *gorm.DB
}

type DBConnectionOpts

type DBConnectionOpts struct {
	Name            string
	Password        string
	Host            string
	Database        string
	MaxIdleConns    uint64
	MaxOpenConns    uint64
	MaxConnLifetime uint64
	OpenFunc        func(dsn string) (DB, error)
}

type GetSignedBlocksByStartingBlockIDOpts

type GetSignedBlocksByStartingBlockIDOpts struct {
	StartingBlockID uint64
}

type GuardianProver

type GuardianProver struct {
	Address            common.Address
	ID                 *big.Int
	HealthCheckCounter prometheus.Counter
	SignedBlockCounter prometheus.Counter
}

func SignatureToGuardianProver

func SignatureToGuardianProver(
	msg []byte,
	b64EncodedSig string,
	guardianProvers []GuardianProver,
) (*GuardianProver, error)

type HealthCheck

type HealthCheck struct {
	ID               int       `json:"id"`
	GuardianProverID uint64    `json:"guardianProverId"`
	Alive            bool      `json:"alive"`
	ExpectedAddress  string    `json:"expectedAddress"`
	RecoveredAddress string    `json:"recoveredAddress"`
	SignedResponse   string    `json:"signedResponse"`
	LatestL1Block    uint64    `json:"latestL1Block"`
	LatestL2Block    uint64    `json:"latestL2Block"`
	CreatedAt        time.Time `json:"createdAt"`
}

type HealthCheckRepository

type HealthCheckRepository interface {
	Get(
		ctx context.Context,
		req *http.Request,
	) (paginate.Page, error)
	GetByGuardianProverID(
		ctx context.Context,
		req *http.Request,
		id int,
	) (paginate.Page, error)
	GetMostRecentByGuardianProverID(
		ctx context.Context,
		req *http.Request,
		id int,
	) (*HealthCheck, error)
	Save(opts SaveHealthCheckOpts) error
	GetUptimeByGuardianProverID(ctx context.Context, id int) (float64, int, error)
}

type NodeInfo

type NodeInfo struct {
	Startup
	LatestL1BlockNumber uint64 `json:"latestL1BlockNumber"`
	LatestL2BlockNumber uint64 `json:"latestL2BlockNumber"`
}

type SaveHealthCheckOpts

type SaveHealthCheckOpts struct {
	GuardianProverID uint64
	Alive            bool
	ExpectedAddress  string
	RecoveredAddress string
	SignedResponse   string
	LatestL1Block    uint64
	LatestL2Block    uint64
}

type SaveSignedBlockOpts

type SaveSignedBlockOpts struct {
	GuardianProverID uint64
	BlockID          uint64
	BlockHash        string
	Signature        string
	RecoveredAddress string
}

type SaveStartupOpts

type SaveStartupOpts struct {
	GuardianProverID      uint64
	GuardianProverAddress string
	Revision              string
	GuardianVersion       string
	L1NodeVersion         string `json:"l1NodeVersion"`
	L2NodeVersion         string `json:"l2NodeVersion"`
}

type SignedBlock

type SignedBlock struct {
	GuardianProverID uint64    `json:"guardianProverID"`
	BlockID          uint64    `json:"blockID"`
	BlockHash        string    `json:"blockHash"`
	Signature        string    `json:"signature"`
	RecoveredAddress string    `json:"recoveredAddress"`
	CreatedAt        time.Time `json:"createdAt"`
}

type SignedBlockRepository

type SignedBlockRepository interface {
	Save(opts SaveSignedBlockOpts) error
	GetByStartingBlockID(opts GetSignedBlocksByStartingBlockIDOpts) ([]*SignedBlock, error)
	GetMostRecentByGuardianProverID(id int) (*SignedBlock, error)
}

SignedBlockRepository defines database interaction methods to create and get signed blocks submitted by guardian provers.

type Startup

type Startup struct {
	GuardianProverID      uint64    `json:"guardianProverID"`
	GuardianProverAddress string    `json:"guardianProverAddress"`
	L1NodeVersion         string    `json:"l1NodeVersion"`
	L2NodeVersion         string    `json:"l2NodeVersion"`
	Revision              string    `json:"revision"`
	GuardianVersion       string    `json:"guardianVersion"`
	CreatedAt             time.Time `json:"createdAt"`
}

Startup represents an individual startup from a guardian prover, every time one boots up, we should receive a startup and save it in the database.

type StartupRepository

type StartupRepository interface {
	GetByGuardianProverID(
		ctx context.Context,
		req *http.Request,
		id int,
	) (paginate.Page, error)
	GetMostRecentByGuardianProverID(
		ctx context.Context,
		id int,
	) (*Startup, error)
	Save(opts SaveStartupOpts) error
}

Directories

Path Synopsis
bindings
cmd
Code generated by swaggo/swag.
Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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