runtime

package
v0.0.0-...-f5f0bdb Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PageSize = 64 * 1024

PageSize ...

View Source
var U32Max = int64(math.Pow(float64(2), float64(32))) - 1

U32Max ...

Functions

This section is empty.

Types

type Crypto

type Crypto struct {
	Heap *Heap
}

Crypto ...

func NewCrypto

func NewCrypto(heap *Heap) *Crypto

NewCrypto ...

func (*Crypto) Blake2b256

func (c *Crypto) Blake2b256(dataPtr Pointer, dataLength int64, outPtr Pointer)

Blake2b256 ...

func (*Crypto) ED25519Verify

func (c *Crypto) ED25519Verify(msgPtr Pointer, msgLength int64, sigPtr Pointer, pubkeyPtr Pointer) int64

ED25519Verify ...

func (*Crypto) Twox128

func (c *Crypto) Twox128(dataPtr Pointer, dataLength int64, outPtr Pointer)

Twox128 ...

func (*Crypto) Twox256

func (c *Crypto) Twox256(dataPtr Pointer, dataLength int64, outPtr Pointer)

Twox256 ...

type Data

type Data struct {
	Heap *Heap
	DB   db.TXDB
}

Data ...

func NewData

func NewData(heap *Heap, dbs db.TXDB) *Data

NewData ...

func (*Data) ClearPrefix

func (d *Data) ClearPrefix(prefixPtr Pointer, prefixLength int64)

ClearPrefix ...

func (*Data) ClearStorage

func (d *Data) ClearStorage(keyPtr Pointer, keyLength int64)

ClearStorage ...

func (*Data) ExistsStorage

func (d *Data) ExistsStorage(keyPtr Pointer, keyLength int64) int

ExistsStorage ...

func (*Data) GetAllocatedStorage

func (d *Data) GetAllocatedStorage(keyPtr Pointer, keyLength int64, lenPtr Pointer) Pointer

GetAllocatedStorage ...

func (*Data) GetStorageInto

func (d *Data) GetStorageInto(keyPtr Pointer, keyLength int64, dataPtr Pointer, dataLength int64, offset int64) int64

GetStorageInto ...

func (*Data) SetStorage

func (d *Data) SetStorage(keyPtr Pointer, keyLength int64, dataPtr Pointer, dataLength int64)

SetStorage ...

type Env

type Env struct {
	DB   *triedb.TrieDB
	Heap *Heap
}

Env ...

func NewEnv

func NewEnv(db *triedb.TrieDB) *Env

NewEnv ...

type Header struct{}

Header ...

type Heap

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

Heap ...

func NewHeap

func NewHeap() *Heap

NewHeap ...

func (*Heap) Allocate

func (h *Heap) Allocate(size int64) Pointer

Allocate ...

func (*Heap) CalculateSize

func (h *Heap) CalculateSize(buffer MemoryBuffer) int64

CalculateSize ...

func (*Heap) Deallocate

func (h *Heap) Deallocate(ptr Pointer) (int64, error)

Deallocate ...

func (*Heap) Dup

func (h *Heap) Dup(ptr Pointer, length int64) []uint8

Dup ...

func (*Heap) Fill

func (h *Heap) Fill(ptr Pointer, value uint8, length int64) []uint8

Fill ...

func (*Heap) FindContaining

func (h *Heap) FindContaining(size int64) Pointer

FindContaining ...

func (*Heap) FreeAlloc

func (h *Heap) FreeAlloc(size int64) Pointer

FreeAlloc ...

func (*Heap) Get

func (h *Heap) Get(ptr Pointer, length int64) []uint8

Get ...

func (*Heap) GetU32

func (h *Heap) GetU32(ptr Pointer) uint32

GetU32 ...

func (*Heap) GrowAlloc

func (h *Heap) GrowAlloc(size int64) Pointer

GrowAlloc ...

func (*Heap) GrowMemory

func (h *Heap) GrowMemory(pages int64) bool

GrowMemory ...

func (*Heap) Set

func (h *Heap) Set(ptr Pointer, data []uint8) Pointer

Set ...

func (*Heap) SetU32

func (h *Heap) SetU32(ptr Pointer, value uint32) Pointer

SetU32 ...

func (*Heap) SetWASMMemory

func (h *Heap) SetWASMMemory(wasmMemory *WasmMemory, pageOffset int64)

SetWASMMemory ...

func (*Heap) Size

func (h *Heap) Size() int64

Size ...

func (*Heap) Used

func (h *Heap) Used() SizeUsed

Used ...

func (*Heap) WasResized

func (h *Heap) WasResized() bool

WasResized ...

type HeapMemory

type HeapMemory struct {
	Allocated   MemoryBuffer
	Deallocated MemoryBuffer
	IsResized   bool
	Offset      int64
	End         int64
	Size        int64
	Buffer      []uint8
}

HeapMemory ...

type Interface

type Interface interface {
}

Interface ...

type InterfaceChain

type InterfaceChain interface {
	ChainID() int
}

InterfaceChain ...

type InterfaceCrypto

type InterfaceCrypto interface {
	Blake2b256(data Pointer, length int64, out Pointer)
	ED25519Verify(msgPtr Pointer, msgLen int64, sigPtr Pointer, pubkeyPtr Pointer) int64
	Twox128(data Pointer, length int64, out Pointer)
	Twox256(data Pointer, length int64, out Pointer)
}

InterfaceCrypto ...

type InterfaceEnvHeap

type InterfaceEnvHeap interface {
	Allocate(size int64) Pointer
	Deallocate(ptr Pointer) (int64, error)
	Dup(ptr Pointer, length int64) []uint8
	Fill(ptr Pointer, value uint8, length int64) []uint8
	Get(ptr Pointer, length int64) []uint8
	GetU32(ptr Pointer) []uint8
	Set(ptr Pointer, data []uint8) Pointer
	SetU32(ptr Pointer, value []uint8) Pointer
	SetWASMMemory(wasmMemory *WasmMemory, pageOffset int64)
	Size() int64
	Used() SizeUsed
	WasResized() bool
}

InterfaceEnvHeap ...

type InterfaceIO

type InterfaceIO interface {
	PrintHex(ptr Pointer, length int64)
	PrintUTF8(ptr Pointer, length int64)
	PrintNumber(hi int64, lo int64)
}

InterfaceIO ...

type InterfaceInstrument

type InterfaceInstrument interface {
	Start()
	Stop() Stats
}

InterfaceInstrument ...

type InterfaceMemory

type InterfaceMemory interface {
	Free(ptr Pointer)
	Malloc(size int64) Pointer
	Memcmp(s1 Pointer, s2 Pointer, length int64) int64
	Memcpy(dst Pointer, src Pointer, num int64) Pointer
	Memmove(dst Pointer, src Pointer, num int64) Pointer
	Memset(dst Pointer, val uint8, num int64) Pointer
}

InterfaceMemory ...

type InterfaceSandbox

type InterfaceSandbox interface {
	Instantiate(a, b, c, d, e, f int64) int64
	InstanceTeardown(instanceIndex int64)
	Invoke(instanceIndex int64, exportPtr Pointer, exportLength int64, argsPtr Pointer, argsLength int64, returnValPtr Pointer, returnValLength int64, state int64)
	MemoryGet(memoryIndex int64, offset int64, ptr Pointer, length int64) int64
	MemoryNew(initial int64, maximum int64) int64
	MemorySet(memoryIndex int64, offset int64, ptr Pointer, length int64) int64
	MemoryTeardown(memoryIndex int64)
}

InterfaceSandbox ...

type InterfaceStorageData

type InterfaceStorageData interface {
	ClearPrefix(prefixPtr Pointer, prefixLength int64)
	ClearStorage(keyPtr Pointer, keyLength int64)
	ExistsStorage(keyPtr Pointer, keyLength int64) int64
	GetAllocatedStorage(keyPtr Pointer, keyLength int64, writtenPtr Pointer) Pointer
	GetStorageInto(keyPtr Pointer, keyLength int64, dataPtr Pointer, dataLength int64, offset int64) int64
	SetStorage(keyPtr Pointer, keyLength int64, dataPtr Pointer, dataLength int64)
}

InterfaceStorageData ...

type InterfaceStorageTrie

type InterfaceStorageTrie interface {
	Blake2b256EnumeratedTrieRoot(valuesPtr Pointer, lensPtr Pointer, lensLength int64, resultPtr Pointer)
	StorageChangesRoot(parentHashData Pointer, parentHashLength, parentNumHi, parentNumLo int64, result Pointer)
	StorageRoot(resultPtr Pointer)
}

InterfaceStorageTrie ...

type Memory

type Memory struct {
	Heap *Heap
	DB   *triedb.TrieDB
}

Memory ...

func NewMemory

func NewMemory(env *Env) *Memory

NewMemory ...

func (*Memory) Free

func (m *Memory) Free(ptr Pointer)

Free ...

func (*Memory) Malloc

func (m *Memory) Malloc(size int64) Pointer

Malloc ...

func (*Memory) Memcmp

func (m *Memory) Memcmp(s1 Pointer, s2 Pointer, length int64) int64

Memcmp ...

func (*Memory) Memcpy

func (m *Memory) Memcpy(dst Pointer, src Pointer, num int64) Pointer

Memcpy ...

func (*Memory) Memmove

func (m *Memory) Memmove(dst Pointer, src Pointer, num int64) Pointer

Memmove ...

func (*Memory) Memset

func (m *Memory) Memset(dst Pointer, val uint8, num int64) Pointer

Memset ...

type MemoryBuffer

type MemoryBuffer map[int64]int64 // offset -> size

MemoryBuffer ...

type Pointer

type Pointer int64

Pointer ...

type Runtime

type Runtime struct {
}

Runtime ...

func NewRuntime

func NewRuntime(stateDB *triedb.TrieDB) *Runtime

NewRuntime ...

type Sandbox

type Sandbox struct {
}

Sandbox ...

func NewSandbox

func NewSandbox(env Env) *Sandbox

NewSandbox ...

func (*Sandbox) InstanceTeardown

func (s *Sandbox) InstanceTeardown(instanceIndex int64)

InstanceTeardown ...

func (*Sandbox) Instantiate

func (s *Sandbox) Instantiate(a, b, c, d, e, f int64) int64

Instantiate ...

func (*Sandbox) Invoke

func (s *Sandbox) Invoke(instanceIndex int64, exportPtr Pointer, exportLength int64, argsPtr Pointer, argsLength int64, returnValPtr Pointer, returnValLength int64, state int64)

Invoke ...

func (*Sandbox) MemoryGet

func (s *Sandbox) MemoryGet(memoryIndex int64, offset int64, ptr Pointer, length int64) int64

MemoryGet ...

func (*Sandbox) MemoryNew

func (s *Sandbox) MemoryNew(initial int64, maximum int64) int64

MemoryNew ...

func (*Sandbox) MemorySet

func (s *Sandbox) MemorySet(memoryIndex int64, offset int64, ptr Pointer, length int64) int64

MemorySet ...

func (*Sandbox) MemoryTeardown

func (s *Sandbox) MemoryTeardown(memoryIndex int64)

MemoryTeardown ...

type SignedBlock

type SignedBlock struct{}

SignedBlock ...

type SizeUsed

type SizeUsed struct {
	Allocated   int64
	Deallocated int64
}

SizeUsed ...

type Stat

type Stat struct {
	Average int64
	Calls   int64
	Elapsed int64
}

Stat ...

type Stats

type Stats map[string]Stat

Stats ...

type Storage

type Storage struct {
	Data *Data
	Trie *Trie
}

Storage ...

func NewStorage

func NewStorage(heap *Heap, dbs db.TXDB) *Storage

NewStorage ...

type Trie

type Trie struct {
	Heap *Heap
	DB   db.TXDB
}

Trie ...

func NewTrie

func NewTrie(heap *Heap, dbs db.TXDB) *Trie

NewTrie ...

func (*Trie) Blake2b256EnumeratedTrieRoot

func (t *Trie) Blake2b256EnumeratedTrieRoot(valuesPtr Pointer, lenPtr Pointer, count int64, resultPtr Pointer)

Blake2b256EnumeratedTrieRoot ...

func (*Trie) StorageChangesRoot

func (t *Trie) StorageChangesRoot(parentHashData Pointer, parentHashLen int64, parentNumHi int64, parentNumLo int64, result Pointer) int64

StorageChangesRoot ...

func (*Trie) StorageRoot

func (t *Trie) StorageRoot(resultPtr Pointer)

StorageRoot ...

type Version

type Version struct {
	// SpecName identifies the different Substrate runtimes. There'll be at least polkadot and node.
	// A different on-chain spec_name to that of the native runtime would normally result
	// in node not attempting to sync or author blocks.
	SpecName string
	// SpecVersion of the runtime specification. A full-node will not attempt to use its native
	// runtime in substitute for the on-chain Wasm runtime unless all of `SpecName`,
	// `SpecVersion` and `AuthoringVersion` are the same between Wasm and native.
	SpecVersion uint32
	// AuthoringVersion of the authorship interface. An authoring node
	// will not attempt to author blocks unless this is equal to its native runtime.
	AuthoringVersion uint32
	// ImplName is the name of the implementation of the spec. This is of little consequence for the node
	// and serves only to differentiate code of different implementation teams. For this
	// codebase, it will be parity-polkadot. If there were a non-Rust implementation of the
	// Polkadot runtime (e.g. C++), then it would identify itself with an accordingly different
	// `ImplName`.
	ImplName string
	// ImplVersion of the implementation of the specification. Nodes are free to ignore this; it
	// serves only as an indication that the code is different; as long as the other two versions
	// are the same then while the actual code may be different, it is nonetheless required to
	// do the same thing.
	// Non-consensus-breaking optimisations are about the only changes that could be made which
	// would result in only the `ImplVersion` changing.
	ImplVersion uint32
	// APIS is a list of supported API "features" along with their versions.
	APIS map[uint8]uint32
}

Version should not be thought of as classic Semver (major/minor/tiny). This triplet have different semantics and mis-interpretation could cause problems. In particular: bug fixes should result in an increment of `SpecVersion` and possibly `AuthoringVersion`, absolutely not `ImplVersion` since they change the semantics of the runtime.

type WasmMemory

type WasmMemory struct {
	Buffer []byte
}

WasmMemory ...

Jump to

Keyboard shortcuts

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