logicrunner

package
v0.7.1-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package logicrunner - infrastructure for executing smartcontracts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeBaseMessage added in v0.5.0

func MakeBaseMessage(req rpctypes.UpBaseReq, es *ExecutionState) message.BaseLogicMessage

MakeBaseMessage makes base of logicrunner event from base of up request

Types

type CaseBind added in v0.4.0

type CaseBind struct {
	Requests []CaseRequest
}

CaseBinder is a whole result of executor efforts on every object it seen on this pulse

func NewCaseBind added in v0.7.5

func NewCaseBind() *CaseBind

func NewCaseBindFromExecutorResultsMessage added in v0.7.5

func NewCaseBindFromExecutorResultsMessage(msg *message.ExecutorResults) *CaseBind

func NewCaseBindFromValidateMessage added in v0.7.5

func NewCaseBindFromValidateMessage(ctx context.Context, mb core.MessageBus, msg *message.ValidateCaseBind) *CaseBind

func (*CaseBind) NewRequest added in v0.7.5

func (cb *CaseBind) NewRequest(p core.Parcel, request Ref, mb core.MessageBus) *CaseRequest

func (*CaseBind) ToValidateMessage added in v0.7.5

func (cb *CaseBind) ToValidateMessage(ctx context.Context, ref Ref, pulse core.Pulse) *message.ValidateCaseBind

type CaseBindReplay added in v0.7.5

type CaseBindReplay struct {
	Pulse    core.Pulse
	CaseBind CaseBind
	Request  int
	Record   int
	Steps    int
	Fail     int
}

func NewCaseBindReplay added in v0.7.5

func NewCaseBindReplay(cb CaseBind) *CaseBindReplay

func (*CaseBindReplay) NextRequest added in v0.7.5

func (r *CaseBindReplay) NextRequest() *CaseRequest

type CaseRequest added in v0.7.5

type CaseRequest struct {
	Parcel     core.Parcel
	Request    core.RecordRef
	MessageBus core.MessageBus
	Reply      core.Reply
	Error      string
}

type Consensus added in v0.6.1

type Consensus struct {
	sync.Mutex

	Have     int
	Need     int
	Total    int
	Results  map[Ref]ConsensusRecord
	CaseBind CaseBind
	Message  core.Parcel
	// contains filtered or unexported fields
}

Consensus is an object for one validation process where all validated results will be compared.

func (*Consensus) AddExecutor added in v0.6.1

func (c *Consensus) AddExecutor(ctx context.Context, sm core.Parcel, msg *message.ExecutorResults)

func (*Consensus) AddValidated added in v0.6.1

func (c *Consensus) AddValidated(ctx context.Context, sm core.Parcel, msg *message.ValidationResults) error

AddValidated adds results from validators

func (*Consensus) CheckReady added in v0.6.1

func (c *Consensus) CheckReady(ctx context.Context)

func (*Consensus) FindRequestBefore added in v0.6.2

func (c *Consensus) FindRequestBefore(steps int) *core.RecordID

FindRequestBefore returns request placed before step (last valid request)

func (*Consensus) GetReference added in v0.6.2

func (c *Consensus) GetReference() Ref

func (*Consensus) GetValidatorSignatures added in v0.6.2

func (c *Consensus) GetValidatorSignatures() (messages []core.Message)

type ConsensusRecord added in v0.6.1

type ConsensusRecord struct {
	Steps   int
	Error   string
	Message core.Parcel
}

type CurrentExecution added in v0.7.5

type CurrentExecution struct {
	Context       context.Context
	LogicContext  *core.LogicCallContext
	Request       *Ref
	Sequence      uint64
	RequesterNode *Ref
	ReturnMode    message.MethodReturnMode
	SentResult    bool
}

type Error added in v0.6.3

type Error struct {
	Err      error
	Request  *Ref
	Contract *Ref
	Method   string
}

func (Error) Error added in v0.6.3

func (lre Error) Error() string

type ExecutionQueueElement added in v0.7.5

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

type ExecutionQueueResult added in v0.7.5

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

type ExecutionState added in v0.6.1

type ExecutionState struct {
	sync.Mutex

	ArtifactManager core.ArtifactManager

	Behaviour ValidationBehaviour

	Current              *CurrentExecution
	Queue                []ExecutionQueueElement
	QueueProcessorActive bool

	PendingConfirmed bool
	// contains filtered or unexported fields
}

func (*ExecutionState) CheckPendingRequests added in v0.7.5

func (es *ExecutionState) CheckPendingRequests(ctx context.Context, inMsg core.Message) (message.PendingState, error)

func (*ExecutionState) WrapError added in v0.7.5

func (es *ExecutionState) WrapError(err error, message string) error

type LogicRunner

type LogicRunner struct {
	// FIXME: Ledger component is deprecated. Inject required sub-components.
	MessageBus                 core.MessageBus                 `inject:""`
	ContractRequester          core.ContractRequester          `inject:""`
	Ledger                     core.Ledger                     `inject:""`
	NodeNetwork                core.NodeNetwork                `inject:""`
	PlatformCryptographyScheme core.PlatformCryptographyScheme `inject:""`
	ParcelFactory              message.ParcelFactory           `inject:""`
	PulseStorage               core.PulseStorage               `inject:""`
	ArtifactManager            core.ArtifactManager            `inject:""`
	JetCoordinator             core.JetCoordinator             `inject:""`

	Executors [core.MachineTypesLastID]core.MachineLogicExecutor

	Cfg *configuration.LogicRunner
	// contains filtered or unexported fields
}

LogicRunner is a general interface of contract executor

func NewLogicRunner added in v0.0.3

func NewLogicRunner(cfg *configuration.LogicRunner) (*LogicRunner, error)

NewLogicRunner is constructor for LogicRunner

func (*LogicRunner) CheckExecutionLoop added in v0.7.5

func (lr *LogicRunner) CheckExecutionLoop(
	ctx context.Context, es *ExecutionState, parcel core.Parcel,
) bool

func (*LogicRunner) CheckOurRole added in v0.6.3

func (lr *LogicRunner) CheckOurRole(ctx context.Context, msg core.Message, role core.DynamicRole) error

func (*LogicRunner) Execute added in v0.0.3

func (lr *LogicRunner) Execute(ctx context.Context, parcel core.Parcel) (core.Reply, error)

Execute runs a method on an object, ATM just thin proxy to `GoPlugin.Exec`

func (*LogicRunner) GetConsensus added in v0.6.1

func (lr *LogicRunner) GetConsensus(ctx context.Context, ref Ref) *Consensus

func (*LogicRunner) GetExecutor added in v0.0.3

GetExecutor returns an executor for the `MachineType` if it was registered (`RegisterExecutor`), returns error otherwise

func (*LogicRunner) GetObjectState added in v0.7.5

func (lr *LogicRunner) GetObjectState(ref Ref) *ObjectState

func (*LogicRunner) HandleExecutorResultsMessage added in v0.7.5

func (lr *LogicRunner) HandleExecutorResultsMessage(ctx context.Context, inmsg core.Parcel) (core.Reply, error)

func (*LogicRunner) HandlePendingFinishedMessage added in v0.7.5

func (lr *LogicRunner) HandlePendingFinishedMessage(
	ctx context.Context, parcel core.Parcel,
) (
	core.Reply, error,
)

func (*LogicRunner) HandleStillExecutingMessage added in v0.7.5

func (lr *LogicRunner) HandleStillExecutingMessage(
	ctx context.Context, parcel core.Parcel,
) (
	core.Reply, error,
)

func (*LogicRunner) HandleValidateCaseBindMessage added in v0.7.5

func (lr *LogicRunner) HandleValidateCaseBindMessage(ctx context.Context, inmsg core.Parcel) (core.Reply, error)

func (*LogicRunner) HandleValidationResultsMessage added in v0.7.5

func (lr *LogicRunner) HandleValidationResultsMessage(ctx context.Context, inmsg core.Parcel) (core.Reply, error)

func (*LogicRunner) MustObjectState added in v0.7.5

func (lr *LogicRunner) MustObjectState(ref Ref) *ObjectState

func (*LogicRunner) OnPulse added in v0.4.0

func (lr *LogicRunner) OnPulse(ctx context.Context, pulse core.Pulse) error

func (*LogicRunner) ProcessExecutionQueue added in v0.7.5

func (lr *LogicRunner) ProcessExecutionQueue(ctx context.Context, es *ExecutionState)

func (*LogicRunner) RegisterExecutor added in v0.0.3

func (lr *LogicRunner) RegisterExecutor(t core.MachineType, e core.MachineLogicExecutor) error

RegisterExecutor registers an executor for particular `MachineType`

func (*LogicRunner) RegisterHandlers added in v0.6.3

func (lr *LogicRunner) RegisterHandlers()

func (*LogicRunner) RegisterRequest added in v0.7.5

func (lr *LogicRunner) RegisterRequest(ctx context.Context, parcel core.Parcel) (*Ref, error)

func (*LogicRunner) Start

func (lr *LogicRunner) Start(ctx context.Context) error

Start starts logic runner component

func (*LogicRunner) StartQueueProcessorIfNeeded added in v0.7.5

func (lr *LogicRunner) StartQueueProcessorIfNeeded(
	ctx context.Context, es *ExecutionState, msg core.Message,
) error

func (*LogicRunner) Stop

func (lr *LogicRunner) Stop(ctx context.Context) error

Stop stops logic runner component and its executors

func (*LogicRunner) UpsertObjectState added in v0.7.5

func (lr *LogicRunner) UpsertObjectState(ref Ref) *ObjectState

func (*LogicRunner) Validate added in v0.5.0

func (lr *LogicRunner) Validate(ctx context.Context, ref Ref, p core.Pulse, cb CaseBind) (int, error)

type ObjectBody added in v0.6.2

type ObjectBody struct {
	Object          []byte
	Prototype       *Ref
	CodeMachineType core.MachineType
	CodeRef         *Ref
	Parent          *Ref
	// contains filtered or unexported fields
}

ObjectBody is an inner representation of object and all it accessory make it private again when we start it serialize before sending

type ObjectState added in v0.7.5

type ObjectState struct {
	sync.Mutex
	Ref *Ref

	ExecutionState *ExecutionState
	Validation     *ExecutionState
	Consensus      *Consensus
}

Context of one contract execution

func (*ObjectState) MustModeState added in v0.7.5

func (st *ObjectState) MustModeState(mode string) (res *ExecutionState)

func (*ObjectState) RefreshConsensus added in v0.7.5

func (st *ObjectState) RefreshConsensus()

func (*ObjectState) StartValidation added in v0.7.5

func (st *ObjectState) StartValidation() *ExecutionState

func (*ObjectState) WrapError added in v0.7.5

func (st *ObjectState) WrapError(err error, message string) error

type RPC added in v0.4.0

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

RPC is a RPC interface for runner to use for various tasks, e.g. code fetching

func StartRPC added in v0.4.0

func StartRPC(ctx context.Context, lr *LogicRunner, ps core.PulseStorage) *RPC

StartRPC starts RPC server for isolated executors to use

func (*RPC) DeactivateObject added in v0.6.0

func (gpr *RPC) DeactivateObject(req rpctypes.UpDeactivateObjectReq, rep *rpctypes.UpDeactivateObjectResp) (err error)

DeactivateObject is an RPC saving data as memory of a contract as child a parent

func (*RPC) GetCode added in v0.4.0

func (gpr *RPC) GetCode(req rpctypes.UpGetCodeReq, reply *rpctypes.UpGetCodeResp) (err error)

GetCode is an RPC retrieving a code by its reference

func (*RPC) GetDelegate added in v0.4.0

func (gpr *RPC) GetDelegate(req rpctypes.UpGetDelegateReq, rep *rpctypes.UpGetDelegateResp) (err error)

GetDelegate is an RPC saving data as memory of a contract as child a parent

func (*RPC) GetObjChildrenIterator added in v0.7.5

func (gpr *RPC) GetObjChildrenIterator(
	req rpctypes.UpGetObjChildrenIteratorReq,
	rep *rpctypes.UpGetObjChildrenIteratorResp,
) (
	err error,
)

GetObjChildrenIterator is an RPC returns an iterator over object children with specified prototype

func (*RPC) RouteCall added in v0.4.0

func (gpr *RPC) RouteCall(req rpctypes.UpRouteReq, rep *rpctypes.UpRouteResp) (err error)

RouteCall routes call from a contract to a contract through event bus.

func (*RPC) SaveAsChild added in v0.4.0

func (gpr *RPC) SaveAsChild(req rpctypes.UpSaveAsChildReq, rep *rpctypes.UpSaveAsChildResp) (err error)

SaveAsChild is an RPC saving data as memory of a contract as child a parent

func (*RPC) SaveAsDelegate added in v0.4.0

func (gpr *RPC) SaveAsDelegate(req rpctypes.UpSaveAsDelegateReq, rep *rpctypes.UpSaveAsDelegateResp) (err error)

SaveAsDelegate is an RPC saving data as memory of a contract as child a parent

type Ref added in v0.6.0

type Ref = core.RecordRef

type ValidationBehaviour added in v0.5.0

type ValidationBehaviour interface {
	Mode() string
	Result(reply core.Reply, err error) error
}

ValidationBehaviour is a special object that responsible for validation behavior of other methods.

type ValidationChecker added in v0.5.0

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

func (*ValidationChecker) Mode added in v0.7.5

func (vb *ValidationChecker) Mode() string

func (*ValidationChecker) NextRequest added in v0.7.5

func (vb *ValidationChecker) NextRequest() *CaseRequest

func (*ValidationChecker) Result added in v0.7.5

func (vb *ValidationChecker) Result(reply core.Reply, err error) error

type ValidationSaver added in v0.5.0

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

func (*ValidationSaver) Mode added in v0.7.5

func (vb *ValidationSaver) Mode() string

func (*ValidationSaver) NewRequest added in v0.7.5

func (vb *ValidationSaver) NewRequest(p core.Parcel, request Ref, mb core.MessageBus)

func (*ValidationSaver) Result added in v0.7.5

func (vb *ValidationSaver) Result(reply core.Reply, err error) error

Directories

Path Synopsis
Package builtin is implementation of builtin contracts engine
Package builtin is implementation of builtin contracts engine
Package goplugin - golang plugin in docker runner
Package goplugin - golang plugin in docker runner
foundation
Package foundation server implementation of smartcontract functions
Package foundation server implementation of smartcontract functions

Jump to

Keyboard shortcuts

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