core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressKey = "address"
	NestedArgs = "args"
)
View Source
const (
	L1Portal            = "l1_portal_address" //#nosec G101: False positive, this isn't a credential
	L2ToL1MessagePasser = "l2_to_l1_address"  //#nosec G101: False positive, this isn't a credential
	L2OutputOracle      = "l2_output_address" //#nosec G101: False positive, this isn't a credential
)
View Source
const (
	AddressPrefix = iota + 1
	NestedPrefix
)
View Source
const (
	UnknownType = "unknown"
)

Variables

This section is empty.

Functions

func NewTransitChannel

func NewTransitChannel() chan TransitData

NewTransitChannel ... Builds new transit channel

Types

type Alert

type Alert struct {
	Dest      AlertDestination
	PUUID     PUUID
	SUUID     SUUID
	Timestamp time.Time
	Ptype     PipelineType

	Content string
}

Alert ... An alert

type AlertDestination

type AlertDestination uint8

AlertDestination ... The destination for an alert

const (
	Slack      AlertDestination = iota + 1
	ThirdParty                  // 2
)

func StringToAlertingDestType

func StringToAlertingDestType(stringType string) AlertDestination

StringToAlertingDestType ... Converts a string to an alerting destination type

func (AlertDestination) String

func (ad AlertDestination) String() string

String ... Converts an alerting destination type to a string

type AlertingPolicy

type AlertingPolicy struct {
	Destination AlertDestination
}

AlertingPolicy ... The alerting policy for an invariant session NOTE - This could be extended to support additional policy metadata like criticality, etc.

type CUUID

type CUUID struct {
	PID  ComponentPID
	UUID UUID
}

Represents a non-deterministic ID that's assigned to every uniquely constructed ETL component

func MakeCUUID

func MakeCUUID(pt PipelineType, ct ComponentType, rt RegisterType, n Network) CUUID

MakeCUUID ... Constructs a component PID sequence & random UUID

func NilCUUID

func NilCUUID() CUUID

NOTE - This is useful for error handling with functions that also return a ComponentID NilCUUID ... Returns a zero'd out or empty component UUID

func (CUUID) String

func (uuid CUUID) String() string

String ... Returns string representation of a component UUID

func (CUUID) Type

func (uuid CUUID) Type() ComponentType

Type ... Returns component type byte value from component UUID

type ChainSubscription

type ChainSubscription uint8
const (
	OnlyLayer1 ChainSubscription = iota + 1
	OnlyLayer2
	BothNetworks
)

type ClientConfig

type ClientConfig struct {
	Network      Network
	PollInterval time.Duration
	NumOfRetries int
	StartHeight  *big.Int
	EndHeight    *big.Int
}

ClientConfig ... Configuration passed through to an oracle component constructor

func (*ClientConfig) Backfill

func (oc *ClientConfig) Backfill() bool

Backfill ... Returns true if the oracle is configured to backfill

func (*ClientConfig) Backtest

func (oc *ClientConfig) Backtest() bool

Backtest ... Returns true if the oracle is configured to backtest

type ComponentPID

type ComponentPID [4]byte

ComponentPID ... Component Primary ID

func (ComponentPID) String

func (pid ComponentPID) String() string

String ... Returns string representation of a component PID

type ComponentType

type ComponentType uint8

ComponentType ... Denotes the ETL component type

const (
	Oracle ComponentType = iota + 1
	Pipe
	Aggregator
)

func (ComponentType) String

func (ct ComponentType) String() string

String ... Converts the component type to a string

type CtxKey

type CtxKey uint8
const (
	Logger CtxKey = iota
	Metrics
	State
	L1Client
	L2Client
	L2Geth
)

type DataRegister

type DataRegister struct {
	Addressing bool
	Sk         *StateKey

	DataType             RegisterType
	ComponentType        ComponentType
	ComponentConstructor interface{}
	Dependencies         []RegisterType
}

DataRegister ... Represents an ETL subsytem data type that can be produced and consumed by heterogenous components

func (*DataRegister) StateKey

func (dr *DataRegister) StateKey() *StateKey

StateKey ... Returns a cloned state key for a data register

func (*DataRegister) Stateful

func (dr *DataRegister) Stateful() bool

Stateful ... Indicates whether the data register has statefulness

type EngineInputRelay

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

EngineInputRelay ... Represents a inter-subsystem relay used to bind final ETL pipeline outputs to risk engine inputs

func NewEngineRelay

func NewEngineRelay(pUUID PUUID, outChan chan InvariantInput) *EngineInputRelay

NewEngineRelay ... Initializer

func (*EngineInputRelay) RelayTransitData

func (eir *EngineInputRelay) RelayTransitData(td TransitData) error

RelayTransitData ... Creates invariant input from transit data to send to risk engine

type Env

type Env string
const (
	Development Env = "development"
	Production  Env = "production"
	Local       Env = "local"
)

type FetchType

type FetchType int
const (
	FetchHeader FetchType = 0
	FetchBlock  FetchType = 1
)

type FilePath

type FilePath string

type InvSessionPID

type InvSessionPID [3]byte

InvSessionPID ... Invariant session Primary ID

func (InvSessionPID) InvType

func (pid InvSessionPID) InvType() InvariantType

InvType ... Returns invariant type decoding from encoded pid byte

func (InvSessionPID) Network

func (pid InvSessionPID) Network() Network

Network ... Returns network decoding from encoded pid byte

func (InvSessionPID) String

func (pid InvSessionPID) String() string

String ... Returns string representation of an invariant session PID

type InvSessionParams

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

InvSessionParams ... Parameters used to initialize an invariant session

func NewSessionParams

func NewSessionParams() *InvSessionParams

NewSessionParams ... Initializes invariant session params

func (*InvSessionParams) Address

func (sp *InvSessionParams) Address() common.Address

Address ... Returns the address from the invariant session params

func (*InvSessionParams) Bytes

func (sp *InvSessionParams) Bytes() []byte

Bytes ... Returns a marshalled byte array of the invariant session params

func (*InvSessionParams) NestedArgs

func (sp *InvSessionParams) NestedArgs() []any

NestedArgs ... Returns the nested arguments from the invariant session params

func (*InvSessionParams) SetNestedArg

func (sp *InvSessionParams) SetNestedArg(arg interface{})

SetNestedArg ... Sets a nested argument in the invariant session params unique nested key/value space

func (*InvSessionParams) SetValue

func (sp *InvSessionParams) SetValue(key string, val any)

SetValue ... Sets a value in the invariant session params

func (*InvSessionParams) Value

func (sp *InvSessionParams) Value(key string) (any, error)

type Invalidation

type Invalidation struct {
	TimeStamp time.Time
	Message   string
}

Invalidation ... Represents an invalidation event

type InvariantInput

type InvariantInput struct {
	PUUID PUUID
	Input TransitData
}

InvariantInput ... Standardized type used to supply the Risk Engine

type InvariantType

type InvariantType uint8

InvariantType ... Represents the type of invariant

const (
	BalanceEnforcement InvariantType = iota + 1
	ContractEvent
	WithdrawalEnforcement
	FaultDetector
)

func StringToInvariantType

func StringToInvariantType(stringType string) InvariantType

StringToInvariantType ... Converts a string to an invariant type

func (InvariantType) String

func (it InvariantType) String() string

String ... Converts an invariant type to a string

type Network

type Network uint8

Network ... Represents the network for which a pipeline's oracle is subscribed to.

const (
	Layer1 Network = iota + 1
	Layer2
)

func StringToNetwork

func StringToNetwork(stringType string) Network

StringToNetwork ... Converts a string to a network

func (Network) String

func (n Network) String() string

String ... Converts a network to a string

type PUUID

type PUUID struct {
	PID  PipelinePID
	UUID UUID
}

Represents a non-deterministic ID that's assigned to every uniquely constructed ETL pipeline

func MakePUUID

func MakePUUID(pt PipelineType, firstCID, lastCID CUUID) PUUID

MakePUUID ... Constructs a pipeline PID sequence & random UUID

func NilPUUID

func NilPUUID() PUUID

NilPUUID ... Returns a zero'd out or empty pipeline UUID

func (PUUID) NetworkType

func (uuid PUUID) NetworkType() Network

func (PUUID) PipelineType

func (uuid PUUID) PipelineType() PipelineType

PipelineType ... Returns pipeline type decoding from encoded pid byte

func (PUUID) String

func (uuid PUUID) String() string

String ... Returns string representation of a pipeline UUID

type PipelineConfig

type PipelineConfig struct {
	Network      Network
	DataType     RegisterType
	PipelineType PipelineType
	ClientConfig *ClientConfig
}

PipelineConfig ... Configuration passed through to a pipeline constructor

type PipelinePID

type PipelinePID [9]byte

Used for local lookups to look for active collisions

func (PipelinePID) String

func (pid PipelinePID) String() string

String ... Returns string representation of a pipeline PID

type PipelineType

type PipelineType uint8

PipelineType ...

const (
	Backtest PipelineType = iota + 1
	Live
	MockTest
)

func StringToPipelineType

func StringToPipelineType(stringType string) PipelineType

StringToPipelineType ... Converts a string to a pipeline type

func (PipelineType) String

func (pt PipelineType) String() string

String ... Converts the pipeline type to a string

type RegisterDependencyPath

type RegisterDependencyPath struct {
	Path []*DataRegister
}

RegisterDependencyPath ... Represents an inclusive acyclic sequential path of data register dependencies

func (RegisterDependencyPath) GeneratePUUID

func (rdp RegisterDependencyPath) GeneratePUUID(pt PipelineType, n Network) PUUID

GeneratePUUID ... Generates a PUUID for an existing dependency path provided an enumerated pipeline and network type

type RegisterType

type RegisterType uint8

RegisterType ... One byte register type enum

const (
	AccountBalance RegisterType = iota + 1
	GethBlock
	EventLog
)

func (RegisterType) String

func (rt RegisterType) String() string

String ... Returns string representation of a register enum

type SUUID

type SUUID struct {
	PID  InvSessionPID
	UUID UUID
}

Represents a non-deterministic ID that's assigned to every uniquely constructed invariant session

func MakeSUUID

func MakeSUUID(n Network, pt PipelineType, invType InvariantType) SUUID

MakeSUUID ... Constructs an invariant PID sequence & random UUID

func NilSUUID

func NilSUUID() SUUID

NilSUUID ... Returns a zero'd out or empty invariant UUID

func (SUUID) String

func (uuid SUUID) String() string

String ... Returns string representation of an invariant session UUID

type SessionConfig

type SessionConfig struct {
	Network   Network
	PT        PipelineType
	AlertDest AlertDestination
	Type      InvariantType
	Params    *InvSessionParams
}

SessionConfig ... Configuration passed through to a session constructor

type StateKey

type StateKey struct {
	Nesting bool
	Prefix  RegisterType
	ID      string

	PUUID *PUUID
}

StateKey ... Represents a key in the state store

func MakeStateKey

func MakeStateKey(pre RegisterType, id string, nest bool) *StateKey

MakeStateKey ... Builds a minimal state key using a prefix and key

func (*StateKey) Clone

func (sk *StateKey) Clone() *StateKey

Clone ... Returns a copy of the state key

func (*StateKey) IsNested

func (sk *StateKey) IsNested() bool

IsNested ... Indicates whether the state key is nested NOTE - This is used to determine if the state key maps to a value slice of state keys in the state store (ie. nested)

func (*StateKey) SetPUUID

func (sk *StateKey) SetPUUID(pUUID PUUID) error

SetPUUID ... Adds a pipeline UUID to the state key prefix and returns a new state key

func (StateKey) String

func (sk StateKey) String() string

String ... Returns a string representation of the state key

type Subsystem

type Subsystem interface {
	EventLoop() error
	Shutdown() error
}

Subsystem ... Represents a subsystem

type Timeouts

type Timeouts int
const (
	EthClientTimeout Timeouts = 20 // in seconds
)

type TransitData

type TransitData struct {
	OriginTS  time.Time
	Timestamp time.Time

	Network Network
	Type    RegisterType

	Address common.Address
	Value   any
}

TransitData ... Standardized type used for data inter-communication between all ETL components and Risk Engine

func NewTransitData

func NewTransitData(rt RegisterType, val any, opts ...TransitOption) TransitData

NewTransitData ... Initializes transit data with supplied options NOTE - transit data is used as a standard data representation for communication between all ETL components and the risk engine

func (*TransitData) Addressed

func (td *TransitData) Addressed() bool

Addressed ... Indicates whether the transit data has an associated address field

type TransitOption

type TransitOption = func(*TransitData)

TransitOption ... Option used to initialize transit data

func WithAddress

func WithAddress(address common.Address) TransitOption

WithAddress ... Injects address to transit data

func WithOriginTS

func WithOriginTS(t time.Time) TransitOption

WithOriginTS ... Injects origin timestamp to transit data

type UUID

type UUID struct {
	uuid.UUID
}

UUID ... third-party wrapper struct for https://pkg.go.dev/github.com/google/UUID

func (UUID) ShortString

func (id UUID) ShortString() string

ShortString ... Short string representation for easier debugging and ensuring conformance with pessimism specific abstractions https://pkg.go.dev/github.com/google/UUID#UUID.String

Jump to

Keyboard shortcuts

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