Skip to content

Feature: Thread-safe ProofBuilder #892

@roger2hk

Description

@roger2hk

Description

The current ProofBuilder is not thread-safe. There is a demand from personality applications to build the proof after the entries have merged into the tree. If there are 500 entries being merged in a batch, the application will then create 500 ProofBuilders fetching the same tiles from the storage and doing the hashing works again and again. This becomes the performance bottleneck which slows down the write QPS.

tessera/client/client.go

Lines 186 to 195 in 05ff747

// NewProofBuilder creates a new ProofBuilder object for a given tree size.
// The returned ProofBuilder can be re-used for proofs related to a given tree size, but
// it is not thread-safe and should not be accessed concurrently.
func NewProofBuilder(ctx context.Context, treeSize uint64, f TileFetcherFunc) (*ProofBuilder, error) {
pb := &ProofBuilder{
treeSize: treeSize,
nodeCache: newNodeCache(f, treeSize),
}
return pb, nil
}

A thread-safe ProofBuilder is needed to generate the proofs concurrently and effectively.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions