Documentation ¶
Index ¶
- func DeserializeBlobToTx(serialisedBlob []byte) (*[]*gethTypes.Transaction, error)
- func SerializeTxToBlob(txs []*gethTypes.Transaction) ([]byte, error)
- type Actor
- type Chunks
- type Collation
- type CollationFetcher
- type CollationHeader
- func (h *CollationHeader) AddSig(sig [32]byte)
- func (h *CollationHeader) ChunkRoot() *common.Hash
- func (h *CollationHeader) DecodeRLP(s *rlp.Stream) error
- func (h *CollationHeader) EncodeRLP() ([]byte, error)
- func (h *CollationHeader) Hash() (hash common.Hash)
- func (h *CollationHeader) Period() *big.Int
- func (h *CollationHeader) ShardID() *big.Int
- func (h *CollationHeader) Sig() [32]byte
- type Node
- type Shard
- func (s *Shard) BodyByChunkRoot(chunkRoot *common.Hash) ([]byte, error)
- func (s *Shard) CanonicalCollation(shardID *big.Int, period *big.Int) (*Collation, error)
- func (s *Shard) CanonicalHeaderHash(shardID *big.Int, period *big.Int) (*common.Hash, error)
- func (s *Shard) CheckAvailability(header *CollationHeader) (bool, error)
- func (s *Shard) ChunkRootfromHeaderHash(headerHash *common.Hash) (*common.Hash, error)
- func (s *Shard) CollationByHeaderHash(headerHash *common.Hash) (*Collation, error)
- func (s *Shard) HeaderByHash(hash *common.Hash) (*CollationHeader, error)
- func (s *Shard) SaveBody(body []byte) error
- func (s *Shard) SaveCollation(collation *Collation) error
- func (s *Shard) SaveHeader(header *CollationHeader) error
- func (s *Shard) SetAvailability(chunkRoot *common.Hash, availability bool) error
- func (s *Shard) SetCanonical(header *CollationHeader) error
- func (s *Shard) ShardID() *big.Int
- func (s *Shard) ValidateShardID(h *CollationHeader) error
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 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 ¶
BytesToChunks takes the collation body bytes and wraps it into type Chunks, which can be merklized.
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) CalculateChunkRoot ¶
func (c *Collation) CalculateChunkRoot()
CalculateChunkRoot updates the collation header's chunk root based on the body.
func (*Collation) CalculatePOC ¶
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 ¶
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 (*Shard) BodyByChunkRoot ¶
BodyByChunkRoot fetches a collation body given its chunk root.
func (*Shard) CanonicalCollation ¶
CanonicalCollation fetches the collation set as canonical in the shardDB.
func (*Shard) CanonicalHeaderHash ¶
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 ¶
ChunkRootfromHeaderHash gets the chunk root of a collation body from the hash of its header.
func (*Shard) CollationByHeaderHash ¶
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) SaveCollation ¶
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 ¶
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) ValidateShardID ¶
func (s *Shard) ValidateShardID(h *CollationHeader) error
ValidateShardID checks if header belongs to shard.