wavelet

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: MIT Imports: 43 Imported by: 0

README

Wavelet

GoDoc Discord MIT licensed Build Status Go Report Card Coverage Statusd

wavelet is an open ledger for scalable, mission-critical, decentralized WebAssembly applications. It's protocol and implementation is written in Go by the Perlin team.

Refer to the docs located here to learn how to locally setup your own three-node cluster, how to write/deploy a WebAssembly smart contract, or how Wavelet actually works.

We're hiring!

Here at Perlin, we spend days and weeks debating, tinkering, and researching what is out there in academia to bring to industries truly resilient, open-source, secure, economic, and decentralized software to empower companies, startups, and users.

Our doors are open to academics that have a knack for distributed systems, engineers that want to explore unknown waters, frontend developers that want to make and evangelize the next generation of customer-facing applications, and graphics designers that yearn to instrument together greater user experiences for decentralized applications.

Contributions

First of all, thank you so much for taking part in our efforts for creating the ultimate decentralized ledger.

All code contributions to wavelet should comply with all idiomatic Go standards listed here.

All commit messages should be in the format:

module_name_1, module_name_2: description of the changes you made to the two
    modules here as a sentence

Be sure to use only imperative, present tense within your commit messages and optionally include motivation for your changes two lines breaks away from your commit message.

This allows other maintainers and contributors to know which modules you are modifying/creating within the code/docs repository.

Lastly, if you'd like to talk to us or any of the team in real-time, be sure to join our Discord server!

We are heavily active, ready to answer any questions/assist you with any code/doc contributions at almost any time.

License

wavelet, and all of its source code is released under the MIT License.

Documentation

Index

Constants

View Source
const (
	SizeTransactionID = blake2b.Size256
	SizeRoundID       = blake2b.Size256
	SizeMerkleNodeID  = md5.Size
	SizeAccountID     = 32
	SizeSignature     = 64
)
View Source
const (
	PageSize = 65536
)
View Source
const (
	SnowballDefaultBeta = 150
)

Variables

View Source
var (
	ZeroTransactionID TransactionID
	ZeroRoundID       RoundID
	ZeroMerkleNodeID  MerkleNodeID
	ZeroAccountID     AccountID
	ZeroSignature     Signature

	ZeroRoundPtr = &Round{}
)
View Source
var (
	ErrNotSmartContract         = errors.New("contract: specified account ID is not a smart contract")
	ErrContractFunctionNotFound = errors.New("contract: smart contract func not found")
)
View Source
var (
	ErrMissingParents     = errors.New("parents for transaction are not in graph")
	ErrAlreadyExists      = errors.New("transaction already exists in the graph")
	ErrDepthLimitExceeded = errors.New("transactions parents exceed depth limit")
)
View Source
var (
	ErrInvalidLengthRpc = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowRpc   = fmt.Errorf("proto: integer overflow")
)

Functions

func AcquireQueue

func AcquireQueue() *queue.Queue

func ApplyBatchTransaction

func ApplyBatchTransaction(snapshot *avl.Tree, round *Round, tx *Transaction) (*avl.Tree, error)

func ApplyContractTransaction

func ApplyContractTransaction(snapshot *avl.Tree, round *Round, tx *Transaction, state *ContractExecutorState) (*avl.Tree, error)

func ApplyStakeTransaction

func ApplyStakeTransaction(snapshot *avl.Tree, round *Round, tx *Transaction) (*avl.Tree, error)

func ApplyTransferTransaction

func ApplyTransferTransaction(snapshot *avl.Tree, round *Round, tx *Transaction, state *ContractExecutorState) (*avl.Tree, error)

func CollectVotes

func CollectVotes(accounts *Accounts, snowball *Snowball, voteChan <-chan vote, wg *sync.WaitGroup)

func ExportGraphDOT

func ExportGraphDOT(round *Round, graph *Graph)

func LoadContractMemorySnapshot

func LoadContractMemorySnapshot(snapshot *avl.Tree, id AccountID) []byte

func ReadAccountBalance

func ReadAccountBalance(tree *avl.Tree, id AccountID) (uint64, bool)

func ReadAccountContractCode

func ReadAccountContractCode(tree *avl.Tree, id TransactionID) ([]byte, bool)

func ReadAccountContractNumPages

func ReadAccountContractNumPages(tree *avl.Tree, id TransactionID) (uint64, bool)

func ReadAccountContractPage

func ReadAccountContractPage(tree *avl.Tree, id TransactionID, idx uint64) ([]byte, bool)

func ReadAccountNonce

func ReadAccountNonce(tree *avl.Tree, id AccountID) (uint64, bool)

func ReadAccountReward

func ReadAccountReward(tree *avl.Tree, id AccountID) (uint64, bool)

func ReadAccountStake

func ReadAccountStake(tree *avl.Tree, id AccountID) (uint64, bool)

func ReadAccountsLen

func ReadAccountsLen(tree *avl.Tree) uint64

func RegisterWaveletServer

func RegisterWaveletServer(s *grpc.Server, srv WaveletServer)

func ReleaseQueue

func ReleaseQueue(q *queue.Queue)

func SaveContractMemorySnapshot

func SaveContractMemorySnapshot(snapshot *avl.Tree, id AccountID, mem []byte)

func SelectPeers

func SelectPeers(peers []*grpc.ClientConn, amount int) ([]*grpc.ClientConn, error)

func StoreRewardWithdrawalRequest

func StoreRewardWithdrawalRequest(tree *avl.Tree, rw RewardWithdrawalRequest)

func StoreRound

func StoreRound(kv store.KV, round Round, currentIx, oldestIx uint32, storedCount uint8) error

func WriteAccountBalance

func WriteAccountBalance(tree *avl.Tree, id AccountID, balance uint64)

func WriteAccountContractCode

func WriteAccountContractCode(tree *avl.Tree, id TransactionID, code []byte)

func WriteAccountContractNumPages

func WriteAccountContractNumPages(tree *avl.Tree, id TransactionID, numPages uint64)

func WriteAccountContractPage

func WriteAccountContractPage(tree *avl.Tree, id TransactionID, idx uint64, page []byte)

func WriteAccountNonce

func WriteAccountNonce(tree *avl.Tree, id AccountID, nonce uint64)

func WriteAccountReward

func WriteAccountReward(tree *avl.Tree, id AccountID, reward uint64)

func WriteAccountStake

func WriteAccountStake(tree *avl.Tree, id AccountID, stake uint64)

func WriteAccountsLen

func WriteAccountsLen(tree *avl.Tree, size uint64)

Types

type AccountID

type AccountID = [SizeAccountID]byte

type Accounts

type Accounts struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewAccounts

func NewAccounts(kv store.KV) *Accounts

func (*Accounts) Commit

func (a *Accounts) Commit(new *avl.Tree) error

func (*Accounts) GC

func (a *Accounts) GC(ctx context.Context)

GC periodically garbage collects every 5 seconds. Only one instance of GC worker can run at any time.

func (*Accounts) Snapshot

func (a *Accounts) Snapshot() *avl.Tree

type Batch

type Batch struct {
	Size     uint8
	Tags     []uint8
	Payloads [][]byte
}

func ParseBatchTransaction

func ParseBatchTransaction(payload []byte) (Batch, error)

ParseBatchTransaction parses and performs sanity checks on the payload of a batch transaction.

type CollapseResults

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

CollapseResults is what is returned by calling CollapseTransactions. Refer to CollapseTransactions to understand what counts of accepted, rejected, or otherwise ignored transactions truly represent after calling CollapseTransactions.

type Contract

type Contract struct {
	GasLimit uint64

	Params []byte
	Code   []byte
}

func ParseContractTransaction

func ParseContractTransaction(payload []byte) (Contract, error)

ParseContractTransaction parses and performs sanity checks on the payload of a contract transaction.

type ContractExecutor

type ContractExecutor struct {
	ID       AccountID
	Snapshot *avl.Tree

	Gas              uint64
	GasLimitExceeded bool

	Payload []byte
	Error   []byte

	Queue []*Transaction
}

func (*ContractExecutor) Execute

func (e *ContractExecutor) Execute(snapshot *avl.Tree, id AccountID, round *Round, tx *Transaction, amount, gasLimit uint64, name string, params, code []byte) error

func (*ContractExecutor) GetCost

func (e *ContractExecutor) GetCost(key string) int64

func (*ContractExecutor) ResolveFunc

func (e *ContractExecutor) ResolveFunc(module, field string) exec.FunctionImport

func (*ContractExecutor) ResolveGlobal

func (e *ContractExecutor) ResolveGlobal(module, field string) int64

type ContractExecutorState

type ContractExecutorState struct {
	Sender   AccountID
	GasLimit uint64
}

type DownloadTxRequest

type DownloadTxRequest struct {
	Ids [][]byte `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"`
}

func (*DownloadTxRequest) Descriptor

func (*DownloadTxRequest) Descriptor() ([]byte, []int)

func (*DownloadTxRequest) GetIds

func (m *DownloadTxRequest) GetIds() [][]byte

func (*DownloadTxRequest) Marshal

func (m *DownloadTxRequest) Marshal() (dAtA []byte, err error)

func (*DownloadTxRequest) MarshalTo

func (m *DownloadTxRequest) MarshalTo(dAtA []byte) (int, error)

func (*DownloadTxRequest) ProtoMessage

func (*DownloadTxRequest) ProtoMessage()

func (*DownloadTxRequest) Reset

func (m *DownloadTxRequest) Reset()

func (*DownloadTxRequest) Size

func (m *DownloadTxRequest) Size() (n int)

func (*DownloadTxRequest) String

func (m *DownloadTxRequest) String() string

func (*DownloadTxRequest) Unmarshal

func (m *DownloadTxRequest) Unmarshal(dAtA []byte) error

func (*DownloadTxRequest) XXX_DiscardUnknown

func (m *DownloadTxRequest) XXX_DiscardUnknown()

func (*DownloadTxRequest) XXX_Marshal

func (m *DownloadTxRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DownloadTxRequest) XXX_Merge

func (m *DownloadTxRequest) XXX_Merge(src proto.Message)

func (*DownloadTxRequest) XXX_Size

func (m *DownloadTxRequest) XXX_Size() int

func (*DownloadTxRequest) XXX_Unmarshal

func (m *DownloadTxRequest) XXX_Unmarshal(b []byte) error

type DownloadTxResponse

type DownloadTxResponse struct {
	Transactions [][]byte `protobuf:"bytes,1,rep,name=transactions,proto3" json:"transactions,omitempty"`
}

func (*DownloadTxResponse) Descriptor

func (*DownloadTxResponse) Descriptor() ([]byte, []int)

func (*DownloadTxResponse) GetTransactions

func (m *DownloadTxResponse) GetTransactions() [][]byte

func (*DownloadTxResponse) Marshal

func (m *DownloadTxResponse) Marshal() (dAtA []byte, err error)

func (*DownloadTxResponse) MarshalTo

func (m *DownloadTxResponse) MarshalTo(dAtA []byte) (int, error)

func (*DownloadTxResponse) ProtoMessage

func (*DownloadTxResponse) ProtoMessage()

func (*DownloadTxResponse) Reset

func (m *DownloadTxResponse) Reset()

func (*DownloadTxResponse) Size

func (m *DownloadTxResponse) Size() (n int)

func (*DownloadTxResponse) String

func (m *DownloadTxResponse) String() string

func (*DownloadTxResponse) Unmarshal

func (m *DownloadTxResponse) Unmarshal(dAtA []byte) error

func (*DownloadTxResponse) XXX_DiscardUnknown

func (m *DownloadTxResponse) XXX_DiscardUnknown()

func (*DownloadTxResponse) XXX_Marshal

func (m *DownloadTxResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*DownloadTxResponse) XXX_Merge

func (m *DownloadTxResponse) XXX_Merge(src proto.Message)

func (*DownloadTxResponse) XXX_Size

func (m *DownloadTxResponse) XXX_Size() int

func (*DownloadTxResponse) XXX_Unmarshal

func (m *DownloadTxResponse) XXX_Unmarshal(b []byte) error

type Empty

type Empty struct {
}

func (*Empty) Descriptor

func (*Empty) Descriptor() ([]byte, []int)

func (*Empty) Marshal

func (m *Empty) Marshal() (dAtA []byte, err error)

func (*Empty) MarshalTo

func (m *Empty) MarshalTo(dAtA []byte) (int, error)

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) Reset

func (m *Empty) Reset()

func (*Empty) Size

func (m *Empty) Size() (n int)

func (*Empty) String

func (m *Empty) String() string

func (*Empty) Unmarshal

func (m *Empty) Unmarshal(dAtA []byte) error

func (*Empty) XXX_DiscardUnknown

func (m *Empty) XXX_DiscardUnknown()

func (*Empty) XXX_Marshal

func (m *Empty) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Empty) XXX_Merge

func (m *Empty) XXX_Merge(src proto.Message)

func (*Empty) XXX_Size

func (m *Empty) XXX_Size() int

func (*Empty) XXX_Unmarshal

func (m *Empty) XXX_Unmarshal(b []byte) error

type Gossiper

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

func NewGossiper

func NewGossiper(ctx context.Context, client *skademlia.Client, metrics *Metrics) *Gossiper

func (*Gossiper) Gossip

func (g *Gossiper) Gossip(transactions [][]byte)

func (*Gossiper) Push

func (g *Gossiper) Push(tx Transaction)

type Graph

type Graph struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewGraph

func NewGraph(opts ...GraphOption) *Graph

func (*Graph) AddTransaction

func (g *Graph) AddTransaction(tx Transaction) error

AddTransaction adds sufficiently valid transactions with a strongly connected ancestry to the graph, and otherwise buffers incomplete transactions, or otherwise rejects invalid transactions.

func (*Graph) DepthLen

func (g *Graph) DepthLen(start *uint64, end *uint64) int

GetTransactionsByDepth returns the number of transactions in graph whose depth is between [start, end].

func (*Graph) FindEligibleCritical

func (g *Graph) FindEligibleCritical(difficulty byte) *Transaction

FindEligibleCritical looks through all transactions in the current round, and returns any one whose number of zero bits prefixed of its seed is >= difficulty.

func (*Graph) FindEligibleParents

func (g *Graph) FindEligibleParents() []*Transaction

FindEligibleParents provides a set of transactions suited to be eligible parents. We consider eligible parents to be transactions closest to the graphs frontier by DEPTH_DIFF that have no children, such that they are leaf nodes of the graph.

func (*Graph) FindTransaction

func (g *Graph) FindTransaction(id TransactionID) *Transaction

FindTransaction returns transaction with id from graph, and nil otherwise.

func (*Graph) GetTransactionsByDepth

func (g *Graph) GetTransactionsByDepth(start *uint64, end *uint64) []*Transaction

GetTransactionsByDepth returns all transactions in graph whose depth is between [start, end].

func (*Graph) Height

func (g *Graph) Height() uint64

Height returns the height of the graph.

func (*Graph) Len

func (g *Graph) Len() int

Len returns the number of transactions in the graph.

func (*Graph) ListTransactions

func (g *Graph) ListTransactions(offset, limit uint64, sender, creator AccountID) (transactions []*Transaction)

func (*Graph) MarkTransactionAsMissing

func (g *Graph) MarkTransactionAsMissing(id TransactionID, depth uint64)

MarkTransactionAsMissing marks a transaction at some given depth to be missing.

func (*Graph) Missing

func (g *Graph) Missing() []TransactionID

func (*Graph) MissingLen

func (g *Graph) MissingLen() int

MissingLen returns the number of known missing transactions of the graph.

func (*Graph) PruneBelowDepth

func (g *Graph) PruneBelowDepth(targetDepth uint64) int

PruneBelowDepth prunes all transactions and their indices that has a depth equal to or less than targetDepth.

func (*Graph) RootDepth

func (g *Graph) RootDepth() uint64

RootDepth returns the current depth of the root transaction of the graph.

func (*Graph) UpdateRoot

func (g *Graph) UpdateRoot(root Transaction)

UpdateRoot forcefully adds a root transaction to the graph, and updates all relevant graph indices as a result of setting a new root with its new depth.

func (*Graph) UpdateRootDepth

func (g *Graph) UpdateRootDepth(rootDepth uint64)

UpdateRootDepth updates the root depth of the graph to disallow new transactions from being added to the graph whose depth is less than root depth by at most DEPTH_DIFF. It additionally clears away any missing transactions that are at a depth below the root depth by more than DEPTH_DIFF.

type GraphOption

type GraphOption func(*Graph)

func VerifySignatures

func VerifySignatures() GraphOption

func WithMetrics

func WithMetrics(metrics *Metrics) GraphOption

func WithRoot

func WithRoot(root Transaction) GraphOption

type LRU

type LRU struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewLRU

func NewLRU(size int) *LRU

type Ledger

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

func NewLedger

func NewLedger(kv store.KV, client *skademlia.Client, genesis *string) *Ledger

func (*Ledger) AddTransaction

func (l *Ledger) AddTransaction(tx Transaction) error

AddTransaction adds a transaction to the ledger. If the transaction has never been added in the ledgers graph before, it is pushed to the gossip mechanism to then be gossiped to this nodes peers. If the transaction is invalid or fails any validation checks, an error is returned. No error is returned if the transaction has already existed int he ledgers graph beforehand.

func (*Ledger) ApplyTransactionToSnapshot

func (l *Ledger) ApplyTransactionToSnapshot(snapshot *avl.Tree, tx *Transaction) error

ApplyTransactionToSnapshot applies a transactions intended changes to a snapshot of the ledgers current state.

func (*Ledger) BroadcastNop

func (l *Ledger) BroadcastNop() *Transaction

BroadcastNop has the node send a nop transaction should they have sufficient balance available. They are broadcasted if no other transaction that is not a nop transaction is not broadcasted by the node after 500 milliseconds. These conditions only apply so long as at least one transaction gets broadcasted by the node within the current round. Once a round is tentatively being finalized, a node will stop broadcasting nops.

func (*Ledger) CollapseTransactions

func (l *Ledger) CollapseTransactions(round uint64, root Transaction, end Transaction, logging bool) (*CollapseResults, error)

CollapseTransactions takes all transactions recorded within a graph depth interval, and applies all valid and available ones to a snapshot of all accounts stored in the ledger. It returns an updated snapshot with all finalized transactions applied, alongside count summaries of the number of applied, rejected, or otherwise ignored transactions.

Transactions that intersect within all paths from the start to end of a depth interval that are also applicable to the ledger state are considered as accepted. Transactions that do not intersect with any of the paths from the start to end of a depth interval t all are considered as ignored transactions. Transactions that fall entirely out of either applied or ignored are considered to be rejected.

It is important to note that transactions that are inspected over are specifically transactions that are within the depth interval (start, end] where start is the interval starting point depth, and end is the interval ending point depth.

func (*Ledger) FeedSendTokenIntoBucket

func (l *Ledger) FeedSendTokenIntoBucket()

func (*Ledger) FinalizeRounds

func (l *Ledger) FinalizeRounds()

FinalizeRounds periodically attempts to find an eligible critical transaction suited for the current round. If it finds one, it will then proceed to perform snowball sampling over its peers to decide on a single critical transaction that serves as an ending point for the current consensus round. The round is finalized, transactions of the finalized round are applied to the current ledger state, and the graph is updated to cleanup artifacts from the old round.

func (*Ledger) Finalizer

func (l *Ledger) Finalizer() *Snowball

Finalizer returns the Snowball finalizer which finalizes the contents of individual consensus rounds.

func (*Ledger) Graph

func (l *Ledger) Graph() *Graph

Graph returns the directed-acyclic-graph of transactions accompanying the ledger.

func (*Ledger) LogChanges

func (l *Ledger) LogChanges(snapshot *avl.Tree, lastRound uint64)

LogChanges logs all changes made to an AVL tree state snapshot for the purposes of logging out changes to account state to Wavelet's HTTP API.

func (*Ledger) PerformConsensus

func (l *Ledger) PerformConsensus()

PerformConsensus spawns workers related to performing consensus, such as pulling missing transactions and incrementally finalizing intervals of transactions in the ledgers graph.

func (*Ledger) Protocol

func (l *Ledger) Protocol() *Protocol

Protocol returns an implementation of WaveletServer to handle incoming RPC and streams for the ledger. The protocol is agnostic to whatever choice of network stack is used with Wavelet, though by default it is intended to be used with gRPC and Noise.

func (*Ledger) PullMissingTransactions

func (l *Ledger) PullMissingTransactions()

PullMissingTransactions is an infinite loop continually sending RPC requests to pull any transactions identified to be missing by the ledger. It periodically samples a random peer from the network, and requests the peer for the contents of all missing transactions by their respective IDs. When the ledger is in amidst synchronizing/teleporting ahead to a new round, the infinite loop will be cleaned up. It is intended to call PullMissingTransactions() in a new goroutine.

func (*Ledger) RewardValidators

func (l *Ledger) RewardValidators(snapshot *avl.Tree, root Transaction, tx *Transaction, logging bool) error

func (*Ledger) Rounds

func (l *Ledger) Rounds() *Rounds

Rounds returns the round manager for the ledger.

func (*Ledger) Snapshot

func (l *Ledger) Snapshot() *avl.Tree

func (*Ledger) SyncToLatestRound

func (l *Ledger) SyncToLatestRound()

func (*Ledger) TakeSendToken

func (l *Ledger) TakeSendToken() bool

type MerkleNodeID

type MerkleNodeID = [SizeMerkleNodeID]byte

type Metrics

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

func NewMetrics

func NewMetrics(ctx context.Context) *Metrics

func (*Metrics) Stop

func (m *Metrics) Stop()

type OutOfSyncRequest

type OutOfSyncRequest struct {
}

func (*OutOfSyncRequest) Descriptor

func (*OutOfSyncRequest) Descriptor() ([]byte, []int)

func (*OutOfSyncRequest) Marshal

func (m *OutOfSyncRequest) Marshal() (dAtA []byte, err error)

func (*OutOfSyncRequest) MarshalTo

func (m *OutOfSyncRequest) MarshalTo(dAtA []byte) (int, error)

func (*OutOfSyncRequest) ProtoMessage

func (*OutOfSyncRequest) ProtoMessage()

func (*OutOfSyncRequest) Reset

func (m *OutOfSyncRequest) Reset()

func (*OutOfSyncRequest) Size

func (m *OutOfSyncRequest) Size() (n int)

func (*OutOfSyncRequest) String

func (m *OutOfSyncRequest) String() string

func (*OutOfSyncRequest) Unmarshal

func (m *OutOfSyncRequest) Unmarshal(dAtA []byte) error

func (*OutOfSyncRequest) XXX_DiscardUnknown

func (m *OutOfSyncRequest) XXX_DiscardUnknown()

func (*OutOfSyncRequest) XXX_Marshal

func (m *OutOfSyncRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OutOfSyncRequest) XXX_Merge

func (m *OutOfSyncRequest) XXX_Merge(src proto.Message)

func (*OutOfSyncRequest) XXX_Size

func (m *OutOfSyncRequest) XXX_Size() int

func (*OutOfSyncRequest) XXX_Unmarshal

func (m *OutOfSyncRequest) XXX_Unmarshal(b []byte) error

type OutOfSyncResponse

type OutOfSyncResponse struct {
	Round []byte `protobuf:"bytes,1,opt,name=round,proto3" json:"round,omitempty"`
}

func (*OutOfSyncResponse) Descriptor

func (*OutOfSyncResponse) Descriptor() ([]byte, []int)

func (*OutOfSyncResponse) GetRound

func (m *OutOfSyncResponse) GetRound() []byte

func (*OutOfSyncResponse) Marshal

func (m *OutOfSyncResponse) Marshal() (dAtA []byte, err error)

func (*OutOfSyncResponse) MarshalTo

func (m *OutOfSyncResponse) MarshalTo(dAtA []byte) (int, error)

func (*OutOfSyncResponse) ProtoMessage

func (*OutOfSyncResponse) ProtoMessage()

func (*OutOfSyncResponse) Reset

func (m *OutOfSyncResponse) Reset()

func (*OutOfSyncResponse) Size

func (m *OutOfSyncResponse) Size() (n int)

func (*OutOfSyncResponse) String

func (m *OutOfSyncResponse) String() string

func (*OutOfSyncResponse) Unmarshal

func (m *OutOfSyncResponse) Unmarshal(dAtA []byte) error

func (*OutOfSyncResponse) XXX_DiscardUnknown

func (m *OutOfSyncResponse) XXX_DiscardUnknown()

func (*OutOfSyncResponse) XXX_Marshal

func (m *OutOfSyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*OutOfSyncResponse) XXX_Merge

func (m *OutOfSyncResponse) XXX_Merge(src proto.Message)

func (*OutOfSyncResponse) XXX_Size

func (m *OutOfSyncResponse) XXX_Size() int

func (*OutOfSyncResponse) XXX_Unmarshal

func (m *OutOfSyncResponse) XXX_Unmarshal(b []byte) error

type Protocol

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

func (*Protocol) CheckOutOfSync

func (*Protocol) DownloadTx

func (p *Protocol) DownloadTx(ctx context.Context, req *DownloadTxRequest) (*DownloadTxResponse, error)

func (*Protocol) Gossip

func (p *Protocol) Gossip(stream Wavelet_GossipServer) error

func (*Protocol) Query

func (p *Protocol) Query(ctx context.Context, req *QueryRequest) (*QueryResponse, error)

func (*Protocol) Sync

func (p *Protocol) Sync(stream Wavelet_SyncServer) error

type QueryRequest

type QueryRequest struct {
	RoundIndex uint64 `protobuf:"varint,1,opt,name=round_index,json=roundIndex,proto3" json:"round_index,omitempty"`
}

func (*QueryRequest) Descriptor

func (*QueryRequest) Descriptor() ([]byte, []int)

func (*QueryRequest) GetRoundIndex

func (m *QueryRequest) GetRoundIndex() uint64

func (*QueryRequest) Marshal

func (m *QueryRequest) Marshal() (dAtA []byte, err error)

func (*QueryRequest) MarshalTo

func (m *QueryRequest) MarshalTo(dAtA []byte) (int, error)

func (*QueryRequest) ProtoMessage

func (*QueryRequest) ProtoMessage()

func (*QueryRequest) Reset

func (m *QueryRequest) Reset()

func (*QueryRequest) Size

func (m *QueryRequest) Size() (n int)

func (*QueryRequest) String

func (m *QueryRequest) String() string

func (*QueryRequest) Unmarshal

func (m *QueryRequest) Unmarshal(dAtA []byte) error

func (*QueryRequest) XXX_DiscardUnknown

func (m *QueryRequest) XXX_DiscardUnknown()

func (*QueryRequest) XXX_Marshal

func (m *QueryRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryRequest) XXX_Merge

func (m *QueryRequest) XXX_Merge(src proto.Message)

func (*QueryRequest) XXX_Size

func (m *QueryRequest) XXX_Size() int

func (*QueryRequest) XXX_Unmarshal

func (m *QueryRequest) XXX_Unmarshal(b []byte) error

type QueryResponse

type QueryResponse struct {
	Round []byte `protobuf:"bytes,1,opt,name=round,proto3" json:"round,omitempty"`
}

func (*QueryResponse) Descriptor

func (*QueryResponse) Descriptor() ([]byte, []int)

func (*QueryResponse) GetRound

func (m *QueryResponse) GetRound() []byte

func (*QueryResponse) Marshal

func (m *QueryResponse) Marshal() (dAtA []byte, err error)

func (*QueryResponse) MarshalTo

func (m *QueryResponse) MarshalTo(dAtA []byte) (int, error)

func (*QueryResponse) ProtoMessage

func (*QueryResponse) ProtoMessage()

func (*QueryResponse) Reset

func (m *QueryResponse) Reset()

func (*QueryResponse) Size

func (m *QueryResponse) Size() (n int)

func (*QueryResponse) String

func (m *QueryResponse) String() string

func (*QueryResponse) Unmarshal

func (m *QueryResponse) Unmarshal(dAtA []byte) error

func (*QueryResponse) XXX_DiscardUnknown

func (m *QueryResponse) XXX_DiscardUnknown()

func (*QueryResponse) XXX_Marshal

func (m *QueryResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*QueryResponse) XXX_Merge

func (m *QueryResponse) XXX_Merge(src proto.Message)

func (*QueryResponse) XXX_Size

func (m *QueryResponse) XXX_Size() int

func (*QueryResponse) XXX_Unmarshal

func (m *QueryResponse) XXX_Unmarshal(b []byte) error

type RewardWithdrawalRequest

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

func GetRewardWithdrawalRequests

func GetRewardWithdrawalRequests(tree *avl.Tree, roundLimit uint64) []RewardWithdrawalRequest

func UnmarshalRewardWithdrawalRequest

func UnmarshalRewardWithdrawalRequest(r io.Reader) (RewardWithdrawalRequest, error)

func (RewardWithdrawalRequest) Key

func (rw RewardWithdrawalRequest) Key() []byte

func (RewardWithdrawalRequest) Marshal

func (rw RewardWithdrawalRequest) Marshal() []byte

type Round

type Round struct {
	ID     RoundID
	Index  uint64
	Merkle MerkleNodeID

	Applied uint64

	Start Transaction
	End   Transaction
}

Round represents a network-wide finalized non-overlapping graph depth interval that is denoted by both a critical starting point transaction, and a critical ending point transaction. They contain the expected Merkle root of the ledgers state. They are denoted by either their index or ID, which is the checksum of applying BLAKE2b over its contents.

func LoadRounds

func LoadRounds(kv store.KV) ([]*Round, uint32, uint32, error)

func NewRound

func NewRound(index uint64, merkle MerkleNodeID, applied uint64, start, end Transaction) Round

func UnmarshalRound

func UnmarshalRound(r io.Reader) (round Round, err error)

func (Round) ExpectedDifficulty

func (r Round) ExpectedDifficulty(min byte, scale float64) byte

func (Round) Marshal

func (r Round) Marshal() []byte

type RoundID

type RoundID = [SizeRoundID]byte

type Rounds

type Rounds struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewRounds

func NewRounds(store store.KV, limit uint8) (*Rounds, error)

func (*Rounds) Count

func (r *Rounds) Count() uint64

func (*Rounds) GetByIndex

func (r *Rounds) GetByIndex(ix uint64) (*Round, error)

func (*Rounds) Latest

func (r *Rounds) Latest() *Round

func (*Rounds) Oldest

func (r *Rounds) Oldest() *Round

func (*Rounds) Save

func (r *Rounds) Save(round *Round) (*Round, error)

type Signature

type Signature = [SizeSignature]byte

type Snowball

type Snowball struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSnowball

func NewSnowball(opts ...SnowballOption) *Snowball

func (*Snowball) Decided

func (s *Snowball) Decided() bool

func (*Snowball) Prefer

func (s *Snowball) Prefer(round *Round)

func (*Snowball) Preferred

func (s *Snowball) Preferred() *Round

func (*Snowball) Progress

func (s *Snowball) Progress() int

func (*Snowball) Reset

func (s *Snowball) Reset()

func (*Snowball) Tick

func (s *Snowball) Tick(round *Round)

type SnowballOption

type SnowballOption func(*Snowball)

func WithBeta

func WithBeta(beta int) SnowballOption

type Stake

type Stake struct {
	Opcode byte
	Amount uint64
}

func ParseStakeTransaction

func ParseStakeTransaction(payload []byte) (Stake, error)

ParseStakeTransaction parses and performs sanity checks on the payload of a stake transaction.

type SyncInfo

type SyncInfo struct {
	LatestRound []byte   `protobuf:"bytes,1,opt,name=latest_round,json=latestRound,proto3" json:"latest_round,omitempty"`
	Checksums   [][]byte `protobuf:"bytes,2,rep,name=checksums,proto3" json:"checksums,omitempty"`
}

func (*SyncInfo) Descriptor

func (*SyncInfo) Descriptor() ([]byte, []int)

func (*SyncInfo) GetChecksums

func (m *SyncInfo) GetChecksums() [][]byte

func (*SyncInfo) GetLatestRound

func (m *SyncInfo) GetLatestRound() []byte

func (*SyncInfo) Marshal

func (m *SyncInfo) Marshal() (dAtA []byte, err error)

func (*SyncInfo) MarshalTo

func (m *SyncInfo) MarshalTo(dAtA []byte) (int, error)

func (*SyncInfo) ProtoMessage

func (*SyncInfo) ProtoMessage()

func (*SyncInfo) Reset

func (m *SyncInfo) Reset()

func (*SyncInfo) Size

func (m *SyncInfo) Size() (n int)

func (*SyncInfo) String

func (m *SyncInfo) String() string

func (*SyncInfo) Unmarshal

func (m *SyncInfo) Unmarshal(dAtA []byte) error

func (*SyncInfo) XXX_DiscardUnknown

func (m *SyncInfo) XXX_DiscardUnknown()

func (*SyncInfo) XXX_Marshal

func (m *SyncInfo) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SyncInfo) XXX_Merge

func (m *SyncInfo) XXX_Merge(src proto.Message)

func (*SyncInfo) XXX_Size

func (m *SyncInfo) XXX_Size() int

func (*SyncInfo) XXX_Unmarshal

func (m *SyncInfo) XXX_Unmarshal(b []byte) error

type SyncRequest

type SyncRequest struct {
	// Types that are valid to be assigned to Data:
	//	*SyncRequest_RoundId
	//	*SyncRequest_Checksum
	Data isSyncRequest_Data `protobuf_oneof:"Data"`
}

func (*SyncRequest) Descriptor

func (*SyncRequest) Descriptor() ([]byte, []int)

func (*SyncRequest) GetChecksum

func (m *SyncRequest) GetChecksum() []byte

func (*SyncRequest) GetData

func (m *SyncRequest) GetData() isSyncRequest_Data

func (*SyncRequest) GetRoundId

func (m *SyncRequest) GetRoundId() uint64

func (*SyncRequest) Marshal

func (m *SyncRequest) Marshal() (dAtA []byte, err error)

func (*SyncRequest) MarshalTo

func (m *SyncRequest) MarshalTo(dAtA []byte) (int, error)

func (*SyncRequest) ProtoMessage

func (*SyncRequest) ProtoMessage()

func (*SyncRequest) Reset

func (m *SyncRequest) Reset()

func (*SyncRequest) Size

func (m *SyncRequest) Size() (n int)

func (*SyncRequest) String

func (m *SyncRequest) String() string

func (*SyncRequest) Unmarshal

func (m *SyncRequest) Unmarshal(dAtA []byte) error

func (*SyncRequest) XXX_DiscardUnknown

func (m *SyncRequest) XXX_DiscardUnknown()

func (*SyncRequest) XXX_Marshal

func (m *SyncRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SyncRequest) XXX_Merge

func (m *SyncRequest) XXX_Merge(src proto.Message)

func (*SyncRequest) XXX_OneofFuncs

func (*SyncRequest) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

func (*SyncRequest) XXX_Size

func (m *SyncRequest) XXX_Size() int

func (*SyncRequest) XXX_Unmarshal

func (m *SyncRequest) XXX_Unmarshal(b []byte) error

type SyncRequest_Checksum

type SyncRequest_Checksum struct {
	Checksum []byte `protobuf:"bytes,2,opt,name=checksum,proto3,oneof"`
}

func (*SyncRequest_Checksum) MarshalTo

func (m *SyncRequest_Checksum) MarshalTo(dAtA []byte) (int, error)

func (*SyncRequest_Checksum) Size

func (m *SyncRequest_Checksum) Size() (n int)

type SyncRequest_RoundId

type SyncRequest_RoundId struct {
	RoundId uint64 `protobuf:"varint,1,opt,name=round_id,json=roundId,proto3,oneof"`
}

func (*SyncRequest_RoundId) MarshalTo

func (m *SyncRequest_RoundId) MarshalTo(dAtA []byte) (int, error)

func (*SyncRequest_RoundId) Size

func (m *SyncRequest_RoundId) Size() (n int)

type SyncResponse

type SyncResponse struct {
	// Types that are valid to be assigned to Data:
	//	*SyncResponse_Header
	//	*SyncResponse_Chunk
	Data isSyncResponse_Data `protobuf_oneof:"Data"`
}

func (*SyncResponse) Descriptor

func (*SyncResponse) Descriptor() ([]byte, []int)

func (*SyncResponse) GetChunk

func (m *SyncResponse) GetChunk() []byte

func (*SyncResponse) GetData

func (m *SyncResponse) GetData() isSyncResponse_Data

func (*SyncResponse) GetHeader

func (m *SyncResponse) GetHeader() *SyncInfo

func (*SyncResponse) Marshal

func (m *SyncResponse) Marshal() (dAtA []byte, err error)

func (*SyncResponse) MarshalTo

func (m *SyncResponse) MarshalTo(dAtA []byte) (int, error)

func (*SyncResponse) ProtoMessage

func (*SyncResponse) ProtoMessage()

func (*SyncResponse) Reset

func (m *SyncResponse) Reset()

func (*SyncResponse) Size

func (m *SyncResponse) Size() (n int)

func (*SyncResponse) String

func (m *SyncResponse) String() string

func (*SyncResponse) Unmarshal

func (m *SyncResponse) Unmarshal(dAtA []byte) error

func (*SyncResponse) XXX_DiscardUnknown

func (m *SyncResponse) XXX_DiscardUnknown()

func (*SyncResponse) XXX_Marshal

func (m *SyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*SyncResponse) XXX_Merge

func (m *SyncResponse) XXX_Merge(src proto.Message)

func (*SyncResponse) XXX_OneofFuncs

func (*SyncResponse) XXX_OneofFuncs() (func(msg proto.Message, b *proto.Buffer) error, func(msg proto.Message, tag, wire int, b *proto.Buffer) (bool, error), func(msg proto.Message) (n int), []interface{})

XXX_OneofFuncs is for the internal use of the proto package.

func (*SyncResponse) XXX_Size

func (m *SyncResponse) XXX_Size() int

func (*SyncResponse) XXX_Unmarshal

func (m *SyncResponse) XXX_Unmarshal(b []byte) error

type SyncResponse_Chunk

type SyncResponse_Chunk struct {
	Chunk []byte `protobuf:"bytes,2,opt,name=chunk,proto3,oneof"`
}

func (*SyncResponse_Chunk) MarshalTo

func (m *SyncResponse_Chunk) MarshalTo(dAtA []byte) (int, error)

func (*SyncResponse_Chunk) Size

func (m *SyncResponse_Chunk) Size() (n int)

type SyncResponse_Header

type SyncResponse_Header struct {
	Header *SyncInfo `protobuf:"bytes,1,opt,name=header,proto3,oneof"`
}

func (*SyncResponse_Header) MarshalTo

func (m *SyncResponse_Header) MarshalTo(dAtA []byte) (int, error)

func (*SyncResponse_Header) Size

func (m *SyncResponse_Header) Size() (n int)

type Transaction

type Transaction struct {
	Sender  AccountID // Transaction sender.
	Creator AccountID // Transaction creator.

	Nonce uint64

	ParentIDs []TransactionID // Transactions parents.

	Depth uint64 // Graph depth.

	Tag     byte
	Payload []byte

	SenderSignature  Signature
	CreatorSignature Signature

	ID TransactionID // BLAKE2b(*).

	Seed    [blake2b.Size256]byte // BLAKE2b(Sender || ParentIDs)
	SeedLen byte                  // Number of prefixed zeroes of BLAKE2b(Sender || ParentIDs).
}

func AttachSenderToTransaction

func AttachSenderToTransaction(sender *skademlia.Keypair, tx Transaction, parents ...*Transaction) Transaction

func NewBatchTransaction

func NewBatchTransaction(creator *skademlia.Keypair, tags []byte, payloads [][]byte) Transaction

func NewTransaction

func NewTransaction(creator *skademlia.Keypair, tag byte, payload []byte) Transaction

func UnmarshalTransaction

func UnmarshalTransaction(r io.Reader) (t Transaction, err error)

func (Transaction) IsCritical

func (tx Transaction) IsCritical(difficulty byte) bool

func (Transaction) LogicalUnits

func (tx Transaction) LogicalUnits() int

LogicalUnits counts the total number of atomic logical units of changes the specified tx comprises of.

func (Transaction) Marshal

func (t Transaction) Marshal() []byte

func (Transaction) String

func (tx Transaction) String() string

type TransactionID

type TransactionID = [SizeTransactionID]byte

type Transactions

type Transactions struct {
	Transactions [][]byte `protobuf:"bytes,1,rep,name=transactions,proto3" json:"transactions,omitempty"`
}

func (*Transactions) Descriptor

func (*Transactions) Descriptor() ([]byte, []int)

func (*Transactions) GetTransactions

func (m *Transactions) GetTransactions() [][]byte

func (*Transactions) Marshal

func (m *Transactions) Marshal() (dAtA []byte, err error)

func (*Transactions) MarshalTo

func (m *Transactions) MarshalTo(dAtA []byte) (int, error)

func (*Transactions) ProtoMessage

func (*Transactions) ProtoMessage()

func (*Transactions) Reset

func (m *Transactions) Reset()

func (*Transactions) Size

func (m *Transactions) Size() (n int)

func (*Transactions) String

func (m *Transactions) String() string

func (*Transactions) Unmarshal

func (m *Transactions) Unmarshal(dAtA []byte) error

func (*Transactions) XXX_DiscardUnknown

func (m *Transactions) XXX_DiscardUnknown()

func (*Transactions) XXX_Marshal

func (m *Transactions) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Transactions) XXX_Merge

func (m *Transactions) XXX_Merge(src proto.Message)

func (*Transactions) XXX_Size

func (m *Transactions) XXX_Size() int

func (*Transactions) XXX_Unmarshal

func (m *Transactions) XXX_Unmarshal(b []byte) error

type Transfer

type Transfer struct {
	Recipient AccountID
	Amount    uint64
	GasLimit  uint64

	FuncName   []byte
	FuncParams []byte
}

func ParseTransferTransaction

func ParseTransferTransaction(payload []byte) (Transfer, error)

ParseTransferTransaction parses and performs sanity checks on the payload of a transfer transaction.

type WaveletClient

type WaveletClient interface {
	Gossip(ctx context.Context, opts ...grpc.CallOption) (Wavelet_GossipClient, error)
	Query(ctx context.Context, in *QueryRequest, opts ...grpc.CallOption) (*QueryResponse, error)
	CheckOutOfSync(ctx context.Context, in *OutOfSyncRequest, opts ...grpc.CallOption) (*OutOfSyncResponse, error)
	Sync(ctx context.Context, opts ...grpc.CallOption) (Wavelet_SyncClient, error)
	DownloadTx(ctx context.Context, in *DownloadTxRequest, opts ...grpc.CallOption) (*DownloadTxResponse, error)
}

WaveletClient is the client API for Wavelet service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewWaveletClient

func NewWaveletClient(cc *grpc.ClientConn) WaveletClient

type WaveletServer

WaveletServer is the server API for Wavelet service.

type Wavelet_GossipClient

type Wavelet_GossipClient interface {
	Send(*Transactions) error
	CloseAndRecv() (*Empty, error)
	grpc.ClientStream
}

type Wavelet_GossipServer

type Wavelet_GossipServer interface {
	SendAndClose(*Empty) error
	Recv() (*Transactions, error)
	grpc.ServerStream
}

type Wavelet_SyncClient

type Wavelet_SyncClient interface {
	Send(*SyncRequest) error
	Recv() (*SyncResponse, error)
	grpc.ClientStream
}

type Wavelet_SyncServer

type Wavelet_SyncServer interface {
	Send(*SyncResponse) error
	Recv() (*SyncRequest, error)
	grpc.ServerStream
}

Directories

Path Synopsis
cmd
benchmark command
graph command
wallet command
wavelet command
wctl command
internal

Jump to

Keyboard shortcuts

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