types

package
v0.0.0-...-dde17ac Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeserializeBlobToTx

func DeserializeBlobToTx(serialisedBlob []byte) (*[]*gethTypes.Transaction, error)

DeserializeBlobToTx takes byte array blob and converts it back to original txs and returns the txs in tx array.

func SerializeTxToBlob

func SerializeTxToBlob(txs []*gethTypes.Transaction) ([]byte, error)

SerializeTxToBlob converts transactions using two steps. First performs RLP encoding, and then blob encoding.

Types

type Actor

type Actor interface {
	shared.Service
}

Actor refers to either a voter, proposer, or observer in the sharding spec.

type Chunks

type Chunks []byte

Chunks is a wrapper around a chunk array to implement DerivableList, which allows us to Merklize the chunks into the chunkRoot.

func BytesToChunks

func BytesToChunks(body []byte) Chunks

BytesToChunks takes the collation body bytes and wraps it into type Chunks, which can be merklized.

func (Chunks) GetRlp

func (ch Chunks) GetRlp(i int) []byte

GetRlp returns the RLP encoding of one chunk from the list.

func (Chunks) Len

func (ch Chunks) Len() int

Len returns the number of chunks in this list.

type Collation

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

Collation defines a base struct that serves as a primitive equivalent of a "block" in a sharded Ethereum blockchain.

func NewCollation

func NewCollation(header *CollationHeader, body []byte, transactions []*gethTypes.Transaction) *Collation

NewCollation initializes a collation and leaves it up to clients to serialize, deserialize and provide the body and transactions upon creation.

func (*Collation) Body

func (c *Collation) Body() []byte

Body returns the collation's byte body.

func (*Collation) CalculateChunkRoot

func (c *Collation) CalculateChunkRoot()

CalculateChunkRoot updates the collation header's chunk root based on the body.

func (*Collation) CalculatePOC

func (c *Collation) CalculatePOC(salt []byte) common.Hash

CalculatePOC calculates the Proof of Custody given the collation body and some salt, which is appended to each chunk in the collation body before it is hashed.

func (*Collation) Header

func (c *Collation) Header() *CollationHeader

Header returns the collation's header.

func (*Collation) ProposerAddress

func (c *Collation) ProposerAddress() *common.Address

ProposerAddress is the coinbase addr of the creator for the collation.

func (*Collation) Transactions

func (c *Collation) Transactions() []*gethTypes.Transaction

Transactions returns an array of tx's in the collation.

type CollationFetcher

type CollationFetcher interface {
	CollationByHeaderHash(headerHash *common.Hash) (*Collation, error)
}

CollationFetcher defines functionality for a struct that is able to extract respond with collation information to the caller. Shard implements this interface.

type CollationHeader

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

CollationHeader base struct.

func NewCollationHeader

func NewCollationHeader(shardID *big.Int, chunkRoot *common.Hash, period *big.Int, proposerAddress *common.Address, proposerSignature [32]byte) *CollationHeader

NewCollationHeader initializes a collation header struct.

func (*CollationHeader) AddSig

func (h *CollationHeader) AddSig(sig [32]byte)

AddSig adds the signature of proposer after collationHeader gets signed.

func (*CollationHeader) ChunkRoot

func (h *CollationHeader) ChunkRoot() *common.Hash

ChunkRoot of the serialized collation body.

func (*CollationHeader) DecodeRLP

func (h *CollationHeader) DecodeRLP(s *rlp.Stream) error

DecodeRLP uses an RLP Stream to populate the data field of a collation header.

func (*CollationHeader) EncodeRLP

func (h *CollationHeader) EncodeRLP() ([]byte, error)

EncodeRLP gives an encoded representation of the collation header.

func (*CollationHeader) Hash

func (h *CollationHeader) Hash() (hash common.Hash)

Hash takes the keccak256 of the collation header's data contents.

func (*CollationHeader) Period

func (h *CollationHeader) Period() *big.Int

Period the collation corresponds to.

func (*CollationHeader) ShardID

func (h *CollationHeader) ShardID() *big.Int

ShardID the collation corresponds to.

func (*CollationHeader) Sig

func (h *CollationHeader) Sig() [32]byte

Sig is the signature the collation corresponds to.

type Node

type Node interface {
	Start()
	Close()
}

Node defines a a sharding-enabled Ethereum instance that provides full control and shared access of necessary components and services for a sharded Ethereum blockchain.

type Shard

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

Shard defines a way for services attached to a sharding-enabled node to instantiate shards with a given ID and backend. This struct serves as an abstraction that contains useful methods to fetch collations corresponding to a shard from the DB, methods to check for data availability, and more.

func NewShard

func NewShard(shardID *big.Int, shardDB essdb.Database) *Shard

NewShard creates an instance of a Shard struct given a shardID.

func (*Shard) BodyByChunkRoot

func (s *Shard) BodyByChunkRoot(chunkRoot *common.Hash) ([]byte, error)

BodyByChunkRoot fetches a collation body given its chunk root.

func (*Shard) CanonicalCollation

func (s *Shard) CanonicalCollation(shardID *big.Int, period *big.Int) (*Collation, error)

CanonicalCollation fetches the collation set as canonical in the shardDB.

func (*Shard) CanonicalHeaderHash

func (s *Shard) CanonicalHeaderHash(shardID *big.Int, period *big.Int) (*common.Hash, error)

CanonicalHeaderHash gets a collation header hash that has been set as canonical for shardID/period pair.

func (*Shard) CheckAvailability

func (s *Shard) CheckAvailability(header *CollationHeader) (bool, error)

CheckAvailability is used by notaries to confirm a header's data availability.

func (*Shard) ChunkRootfromHeaderHash

func (s *Shard) ChunkRootfromHeaderHash(headerHash *common.Hash) (*common.Hash, error)

ChunkRootfromHeaderHash gets the chunk root of a collation body from the hash of its header.

func (*Shard) CollationByHeaderHash

func (s *Shard) CollationByHeaderHash(headerHash *common.Hash) (*Collation, error)

CollationByHeaderHash fetches a collation by its header's hash from the DB.

func (*Shard) HeaderByHash

func (s *Shard) HeaderByHash(hash *common.Hash) (*CollationHeader, error)

HeaderByHash looks up a collation header from the shardDB using the header's hash.

func (*Shard) SaveBody

func (s *Shard) SaveBody(body []byte) error

SaveBody adds the collation body to the shardDB and sets availability.

func (*Shard) SaveCollation

func (s *Shard) SaveCollation(collation *Collation) error

SaveCollation adds the collation's header and body to shardDB.

func (*Shard) SaveHeader

func (s *Shard) SaveHeader(header *CollationHeader) error

SaveHeader adds the collation header to shardDB.

func (*Shard) SetAvailability

func (s *Shard) SetAvailability(chunkRoot *common.Hash, availability bool) error

SetAvailability saves the availability of the chunk root in the shardDB.

func (*Shard) SetCanonical

func (s *Shard) SetCanonical(header *CollationHeader) error

SetCanonical sets the collation header as canonical in the shardDB. This is called after the period is over and over 2/3 notaries voted on the header.

func (*Shard) ShardID

func (s *Shard) ShardID() *big.Int

ShardID gets the shard's unique identifier.

func (*Shard) ValidateShardID

func (s *Shard) ValidateShardID(h *CollationHeader) error

ValidateShardID checks if header belongs to shard.

Jump to

Keyboard shortcuts

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