results

package module
v0.0.0-...-e01a366 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 15 Imported by: 0

README

results

Cloud func that receives results from a pubsub topic.

Results are received as a JSON object:

  • index:int (for pagination purposes)
  • success:bool
  • post-hash:string
  • state-root:hex-string
  • client-name:string
  • client-version:string
  • key:string (of the task)
  • files:map
    • post-state:string (URL to file)
    • err-log:string (URL to file)
    • out-log:string (URL to file)

The environment var MUSKOKA_CLIENT_NAME must match the client-name to be accepted. In the future multiple client-name inputs may be accepted with other settings.

There results are put into firestore:

  • Same data as JSON input, excl repeat of the task key, the result is merged in as nested data.
  • Result data is merged into results value of the targeted task in the transitions collection. Key: <task key>.results.<result key>. Data: {success: bool, created: time, client-name: string, client-version: string, post-hash: string, files: map}
  • Worker is registered to have produced a result, by merging in the following keys into the task:
    • <taks key>.workers.<worker client name> is set to true.
    • <task key>.workers-versioned.<worker client name> is set to <worker client version>
    • <task key>.has-fail is set to true if the result was not a success

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CheckClient = func(name string) bool {
	return false
}

default: every client is denied.

View Source
var KeyRegex, _ = regexp.Compile("^[-0-9a-zA-Z=][-_0-9a-zA-Z=]{0,128}$")

make sure keys don't start with `__`, or underscores at all

View Source
var RootRegex, _ = regexp.Compile("^0x[0-9a-f]{64}$")

hex encoded bytes32, with 0x prefix

View Source
var VersionRegex, _ = regexp.Compile("^[0-9a-zA-Z][-_.0-9a-zA-Z]{0,128}$")

versions are not used as keys in firestore, and may contain dots.

Functions

func Results

func Results(ctx context.Context, m *pubsub.Message) error

Client auth is checked by configuring the cloud function to only consume messages from a topic specific to the client. And setting the ETH2_CLIENT_NAME environment var.

Types

type PubSubMessage

type PubSubMessage struct {
	Data []byte
}

PubSubMessage is the payload of a Pub/Sub event.

type ResultEntry

type ResultEntry struct {
	Success       bool           `firestore:"success"`
	Created       time.Time      `firestore:"created"`
	ClientName    string         `firestore:"client-name"`
	ClientVersion string         `firestore:"client-version"`
	PostHash      string         `firestore:"post-hash"`
	Files         ResultFilesRef `firestore:"files"`
}

type ResultFilesData

type ResultFilesData struct {
	// urls to the files
	PostState string `json:"post-state"`
	ErrLog    string `json:"err-log"`
	OutLog    string `json:"out-log"`
}

type ResultFilesRef

type ResultFilesRef struct {
	PostState string `firestore:"post-state"`
	ErrLog    string `firestore:"err-log"`
	OutLog    string `firestore:"out-log"`
}

type ResultMsg

type ResultMsg struct {
	// if the transition was successful (i.e. no err log)
	Success bool `json:"success"`
	// the flat-hash of the post-state SSZ bytes, for quickly finding different results.
	PostHash string `json:"post-hash"`
	// the name of the client; 'zrnt', 'lighthouse', etc.
	ClientName string `json:"client-name"`
	// the version number of the client, may contain a git commit hash
	ClientVersion string `json:"client-version"`
	// identifies the transition task
	Key string `json:"key"`
	// Result files
	Files ResultFilesData `json:"files"`
}

type Task

type Task struct {
	Index            int                    `firestore:"index"`
	Blocks           int                    `firestore:"blocks"`
	SpecVersion      string                 `firestore:"spec-version"`
	SpecConfig       string                 `firestore:"spec-config"`
	Created          time.Time              `firestore:"created"`
	Results          map[string]ResultEntry `firestore:"results"`
	WorkersVersioned map[string]string      `firestore:"workers-versioned"`
	Workers          map[string]bool        `firestore:"workers"`
	HasFail          bool                   `firestore:"has-fail"`
}

Jump to

Keyboard shortcuts

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