sandbox

package
v2.3.7 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

View Source
const (
	SHOWLINE        = true
	LEVEL_DEBUG     = "DEBUG"
	LEVEL_INFO      = "INFO"
	LEVEL_WARN      = "WARN"
	LEVEL_ERROR     = "ERROR"
	MODULE_SANDBOX  = "Sandbox"
	MODULE_CONTRACT = "Contract"
)
View Source
const (
	ExitCode_UNKNOWN = 1
	ExitCode_SIGINT  = 128 + 2
	ExitCode_SIGTERM = 128 + 15
)
View Source
const BufferSize = 1024 * 1024

Variables

This section is empty.

Functions

func CustomLevelEncoder

func CustomLevelEncoder(level zapcore.Level, enc zapcore.PrimitiveArrayEncoder)

func CustomTimeEncoder

func CustomTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func EnterNextStep

func EnterNextStep(msg *protogo.DockerVMMessage, stepType protogo.StepType, log string)

EnterNextStep enter next duration tx step

func GetAllStackMsg

func GetAllStackMsg() string

func GetClientStream

GetClientStream get rpc stream

func PrintTxSteps

func PrintTxSteps(msg *protogo.DockerVMMessage) string

PrintTxSteps print all duration tx steps

func PrintTxStepsWithTime

func PrintTxStepsWithTime(msg *protogo.DockerVMMessage, untilDuration time.Duration) (string, bool)

PrintTxStepsWithTime print all duration tx steps with time limt

func Start

func Start(contract sdk.Contract) error

Types

type Conf

type Conf struct {
	ProcessName          string
	ContractName         string
	ContractAddr         string
	LogLevel             string
	ContractEngineClient *ContractEngineClientConf
	RuntimeClient        *RuntimeClientConf
	DisableSlowLog       bool
}

type ContractEngineClient

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

func (*ContractEngineClient) PutFinishMsg

func (c *ContractEngineClient) PutFinishMsg(msg *protogo.DockerVMMessage)

func (*ContractEngineClient) RegisterTxRequestPutFunc

func (c *ContractEngineClient) RegisterTxRequestPutFunc(txRequestPutFunc func(msg *protogo.DockerVMMessage,
	txFinishMsgNotifyFunc func(signal *protogo.DockerVMMessage)))

RegisterTxRequestPutFunc register put func to send txRequest to txHandler with a callback fun that returns a finish signal

func (*ContractEngineClient) Start

func (c *ContractEngineClient) Start() error

type ContractEngineClientConf

type ContractEngineClientConf struct {
	EngineUDSSockPath string
	MaxSendMsgSize    int
	MaxRecvMsgSize    int
}

type PRCProtocolType

type PRCProtocolType int
const (
	UDS PRCProtocolType = iota
	TCP
)

type RuntimeClient

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

func (*RuntimeClient) PutMsg

func (r *RuntimeClient) PutMsg(msg *protogo.DockerVMMessage)

PutMsg put msg to send channel

func (*RuntimeClient) PutMsgWithNotify

func (r *RuntimeClient) PutMsgWithNotify(msg *protogo.DockerVMMessage,
	syscallResponseNotifyFunc func(msg *protogo.DockerVMMessage))

PutMsgWithNotify put msg nad register call back func for sys_call response

func (*RuntimeClient) RegisterResponseNotifier

func (r *RuntimeClient) RegisterResponseNotifier(syscallResponseNotifyFunc func(msg *protogo.DockerVMMessage))

RegisterResponseNotifier register callback func for sys_call response

func (*RuntimeClient) Start

func (r *RuntimeClient) Start() error

type RuntimeClientConf

type RuntimeClientConf struct {
	RuntimeRPCProtocolType PRCProtocolType
	RuntimeHost            string
	RuntimePort            string
	RuntimeUDSSockPath     string
	MaxSendMsgSize         int
	MaxRecvMsgSize         int
}

type SysCallDuration

type SysCallDuration struct {
	OpType        protogo.DockerVMType
	StartTime     int64
	TotalDuration int64
}

func (*SysCallDuration) ToString

func (s *SysCallDuration) ToString() string

type TxDuration

type TxDuration struct {
	Tx                *protogo.DockerVMMessage
	StartTime         int64
	EndTime           int64
	TotalDuration     int64
	SysCallCnt        int32
	SysCallDuration   int64
	CrossCallCnt      int32
	CrossCallDuration int64
	SysCallList       []*SysCallDuration
}

func NewTxDuration

func NewTxDuration(tx *protogo.DockerVMMessage, startTime int64) *TxDuration

func (*TxDuration) EndSysCall

func (t *TxDuration) EndSysCall(msg *protogo.DockerVMMessage) error

EndSysCall close new sys call

func (*TxDuration) GetLatestSysCall

func (t *TxDuration) GetLatestSysCall() (*SysCallDuration, error)

GetLatestSysCall returns latest sys call

func (*TxDuration) PrintSysCallList

func (t *TxDuration) PrintSysCallList() string

func (*TxDuration) Reset

func (t *TxDuration) Reset(tx *protogo.DockerVMMessage, startTime int64)

func (*TxDuration) StartSysCall

func (t *TxDuration) StartSysCall(msg *protogo.DockerVMMessage)

StartSysCall start new sys call

func (*TxDuration) ToString

func (t *TxDuration) ToString() string

type TxHandler

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

func (*TxHandler) PutMsg

func (h *TxHandler) PutMsg(msg *protogo.DockerVMMessage)

PutMsg put txRequest to pendingQueue

func (*TxHandler) PutMsgWithNotify

func (h *TxHandler) PutMsgWithNotify(msg *protogo.DockerVMMessage,
	txFinishMsgNotifyFunc func(msg *protogo.DockerVMMessage))

PutMsgWithNotify put tx request to handler and register finish signal callback func

func (*TxHandler) RegisterSyscallMsgSendFunc

func (h *TxHandler) RegisterSyscallMsgSendFunc(f func(msg *protogo.DockerVMMessage,
	syscallResponseNotifyFunc func(msg *protogo.DockerVMMessage)))

RegisterSyscallMsgSendFunc register runtime client syscall func with call back func

func (*TxHandler) RegisterTxFinishMsgNotifyFunc

func (h *TxHandler) RegisterTxFinishMsgNotifyFunc(txFinishMsgNotifyFunc func(msg *protogo.DockerVMMessage))

RegisterTxFinishMsgNotifyFunc register func to send tx finish msg to engine

func (*TxHandler) Start

func (h *TxHandler) Start() error

type TxStatus

type TxStatus string
const (
	BeforeListening        TxStatus = "before listening"
	BeforeReceive          TxStatus = "before receive"
	BeforeExecute          TxStatus = "before execute"
	Executing              TxStatus = "executing"
	WaitingSysCallResponse TxStatus = "waiting syscall response"
	AfterExecuted          TxStatus = "after executed"
	AfterSendResponse      TxStatus = "after send response"
	Finished               TxStatus = "finished"
)

Jump to

Keyboard shortcuts

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