mock

package
v0.11.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConstructor added in v0.9.0

func NewConstructor(squareSize uint64, opts ...nmt.Option) rsmt2d.TreeConstructorFn

NewConstructor creates a tree constructor function as required by rsmt2d to calculate the data root. It creates that tree using the wrapper.ErasuredNamespacedMerkleTree.

func RandEDS added in v0.9.0

func RandEDS(size int) (*rsmt2d.ExtendedDataSquare, error)

RandEDS generates EDS filled with the random data with the given size for original square. It uses require.TestingT to be able to take both a *testing.T and a *testing.B.

func RandNamespace added in v0.9.0

func RandNamespace() share.Namespace

RandNamespace generates random valid data namespace for testing purposes.

func RandShares added in v0.9.0

func RandShares(total int) ([]share.Share, error)

RandShares generate 'total' amount of shares filled with random data. It uses require.TestingT to be able to take both a *testing.T and a *testing.B.

Types

type DataAvailabilityLayerClient

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

DataAvailabilityLayerClient is intended only for usage in tests. It does actually ensures DA - it stores data in-memory.

func (*DataAvailabilityLayerClient) GetHeaderByHeight added in v0.9.0

func (m *DataAvailabilityLayerClient) GetHeaderByHeight(height uint64) *core.DataAvailabilityHeader

GetHeaderByHeight returns the header at the given height.

func (*DataAvailabilityLayerClient) GetHeightByHeader added in v0.9.0

GetHeightByHeader returns the height for the given header.

func (*DataAvailabilityLayerClient) Init

func (m *DataAvailabilityLayerClient) Init(_ types.NamespaceID, config []byte, dalcKV ds.Datastore, logger log.Logger) error

Init is called once to allow DA client to read configuration and initialize resources.

func (*DataAvailabilityLayerClient) RetrieveBlocks

func (m *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, daHeight uint64) da.ResultRetrieveBlocks

RetrieveBlocks returns block at given height from data availability layer.

func (*DataAvailabilityLayerClient) Start

Start implements DataAvailabilityLayerClient interface.

func (*DataAvailabilityLayerClient) Stop

Stop implements DataAvailabilityLayerClient interface.

func (*DataAvailabilityLayerClient) SubmitBlocks added in v0.10.0

SubmitBlocks submits the passed in blocks to the DA layer. This should create a transaction which (potentially) triggers a state transition in the DA layer.

type ErasuredNamespacedMerkleTree added in v0.9.0

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

ErasuredNamespacedMerkleTree wraps NamespaceMerkleTree to conform to the rsmt2d.Tree interface while also providing the correct namespaces to the underlying NamespaceMerkleTree. It does this by adding the already included namespace to the first half of the tree, and then uses the parity namespace ID for each share pushed to the second half of the tree. This allows for the namespaces to be included in the erasure data, while also keeping the nmt library sufficiently general

func NewErasuredNamespacedMerkleTree added in v0.9.0

func NewErasuredNamespacedMerkleTree(squareSize uint64, axisIndex uint, options ...nmt.Option) ErasuredNamespacedMerkleTree

NewErasuredNamespacedMerkleTree creates a new ErasuredNamespacedMerkleTree with an underlying NMT of namespace size `namespace.NamespaceSize` and with `ignoreMaxNamespace=true`. axisIndex is the index of the row or column that this tree is committing to. squareSize must be greater than zero.

func (*ErasuredNamespacedMerkleTree) ProveRange added in v0.9.0

func (w *ErasuredNamespacedMerkleTree) ProveRange(start, end int) (nmt.Proof, error)

ProveRange returns a Merkle range proof for the leaf range [start, end] where `end` is non-inclusive.

func (*ErasuredNamespacedMerkleTree) Push added in v0.9.0

func (w *ErasuredNamespacedMerkleTree) Push(data []byte) error

Push adds the provided data to the underlying NamespaceMerkleTree, and automatically uses the first DefaultNamespaceIDLen number of bytes as the namespace unless the data pushed to the second half of the tree. Fulfills the rsmt.Tree interface. NOTE: panics if an error is encountered while pushing or if the tree size is exceeded.

func (*ErasuredNamespacedMerkleTree) Root added in v0.9.0

func (w *ErasuredNamespacedMerkleTree) Root() ([]byte, error)

Root fulfills the rsmt.Tree interface by generating and returning the underlying NamespaceMerkleTree Root.

Jump to

Keyboard shortcuts

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