VeChain Docs
  • Welcome to VeChain
  • Blockchain Basics
    • Introduction to blockchain
    • Introduction to digital property
    • The evolution of the internet
  • Introduction to VeChain
    • About the VeChain blockchain
      • Consensus Deep Dive
      • Governance
    • Dual-Token Economic Model
      • VeChain (VET)
      • VeThor (VTHO)
    • Acquire VeChain Assets
    • Sustainability
  • Core Concepts
    • Networks
      • Thor Solo Node
      • Testnet
      • Mainnet
    • Nodes
      • Node Rewards Programme
    • Blocks
      • Block Model
    • Transactions
      • Transaction Model
      • Transaction Fees
      • Transaction Calculation
      • Meta Transaction Features
        • Transaction Uniqueness
        • Controllable Transaction Lifecycle
        • Clauses (Multi-Task Transaction)
        • Fee Delegation
          • Multi-Party Payment (MPP)
          • Designated Gas Payer (VIP-191)
        • Transaction Dependency
    • Block Explorers
    • Wallets
      • VeWorld
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync2
        • User Guide
          • Setup
          • Wallet
          • Signing
          • Activities
          • Settings
        • FAQ
      • Sync
        • User Guide
          • Wallet
          • Ledger Device
          • Browser dApps and web
          • Interact with dApps
          • Activities
          • Settings
          • Report an Issue
          • Contributing
        • FAQ
    • EVM Compatibility
      • VeChain Modifications
      • Methodology
      • Test Coverage
        • Gas model
        • Raw transaction
        • hardhat specific
          • Ganache failures
          • evm_increaseTime
        • Failures in constructor
        • eth_sign
        • Contract address prediction
        • BadBeacon proxy address at 0x1
      • How to Recreate
      • Additional Information
        • Using Governance Contracts
        • ERC1820/ERC777 Testnet
        • Delegate Options
    • Account Abstraction
      • UserOperation
      • Bundler
      • EntryPoint Contract
      • Account Factory Contract
      • Paymaster Contract
    • Token Bound Accounts
  • How to run a node
    • Nodes
    • How to run a Thor Solo Node
    • Custom Network
    • Connect Sync2 to a Thor Solo Node
  • Developer Resources
    • Getting Started
    • How to build on VeChain
      • Connect to the Network
      • Read Data
        • Read Blocks
        • Read Transactions
        • Read Accounts
        • States & Views
        • Events & Logs
        • VET Transfers
      • Write Data
        • Transactions
        • Fee Delegation
      • Listen to Changes
        • Events
        • VET Transfers
        • Transactions
        • Blocks
        • Beats
      • Build with Hardhat
      • Utilities
        • BigInt and Unit-Handling
        • Name Service Lookups
    • Example dApps
      • Buy me a Coffee
      • Token Bound Accounts
      • PWA with Privy and Account Abstraction
    • EVM Compatibility for Developers
      • Key Architectural Differences and Optimizations
      • Practical Implications for Developers: Key Considerations
      • RPC Methods (Detailed Breakdown)
      • Frequently Asked Questions (FAQs)
      • VeChain Blockchain Specifications
      • Key Differences Between VeChain and Ethereum (Summary)
      • Best Practices for Developing on VeChainThor
    • How to verify Address-Ownership
      • Next.js Session Verification
    • Debug Reverted Transactions
    • Account Abstraction
    • VIP-191: Designated Gas Payer
      • How to Integrate VIP-191 (I)
      • How to Integrate VIP-191 (II)
      • How to Integrate VIP-191 (III)
    • Index with Graph Node
      • Setup with Docker
      • Index with OpenZeppelin
        • Create Subgraph Project
        • Configure Contracts
        • Deploy Subgraph and start Indexing
        • Track Subgraph Indexing
        • Access Subgraph
        • Update Subgraph
    • SDKs & Providers
      • SDK
        • Architecture
        • Accounts
        • Bloom Filter
        • Certificates
        • Contracts
        • Cryptography
        • Debug
        • Encoding
        • Polls
        • Subscriptions
        • Thor Client
        • Transactions
      • Thor DevKit
        • Installation
        • Usage
          • Cryptography
          • Accounts
          • Encoding
          • Transactions
          • Certificates
          • Bloom Filter
      • DApp Kit
        • v2
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
        • v1
          • Installation
          • React
            • Installation
            • Usage
          • Vanilla JS
            • Installation
            • Usage
          • Core
            • Installation
            • Usage
          • Theme Variables
          • i18n
          • Node Polyfills
          • V0 to V1
        • v0
          • Installation
          • Usage
          • React
            • Installation
            • Usage
          • Vanilla (UI)
            • Installation
            • Usage
          • Styles (UI)
          • i18n
      • DevPal
      • Web3-Providers-Connex
        • Installation
        • Usage
      • Connex
        • Installation
        • API Specification
    • Frameworks & IDEs
      • Hardhat
      • Remix
    • Built-in Contracts
    • VORJ
    • Useful Links
  • How to contribute
Powered by GitBook
On this page
  • What is the bloom filter data structure?
  • How is the bloom filter used in VeChainThor?
  • The impact of bloom filter

Was this helpful?

  1. Developer Resources
  2. SDKs & Providers
  3. SDK

Bloom Filter

Handling of the bloom filter data structure.

What is the bloom filter data structure?

This data structure was first introduced by Burton H. Bloom in 1970 and has since found extensive utilisation in various domains due to its ability to drastically reduce the need for expensive storage and computational resources. The bloom filter achieves this by representing the set membership information in a compact manner, thereby significantly reducing the memory footprint required to store the set elements.

The bloom filter remains a valuable and widely employed data structure for optimising set membership queries in scenarios where approximate answers are acceptable, and the preservation of storage and computational resources is of paramount importance. Its versatility and effectiveness makes it an indispensable tool in modern computer science and information technology applications.

How is the bloom filter used in VeChainThor?

The VeChainThor blockchain implements the bloom filters as an integral part of its architecture to enhance the management and processing of addresses and block numbers within the ledger. By incorporating bloom filters, VeChainThor optimises the efficiency of address and block lookup operations, thereby streamlining data retrieval processes and enhancing overall system performance.

The primary purpose of the bloom filter is to efficiently determine the presence or absence of a specific address or block number within the blockchain ledger. If a query is made to ascertain the existence of an address or block number, the bloom filter promptly provides a response, indicating whether the queried element is not present in the ledger. This response is guaranteed to be accurate in such cases.

However, when the bloom filter indicates that the queried element is potentially present in the ledger, a higher level of assurance is required due to the probabilistic nature of the data structure. In these scenarios, a subsequent search operation is performed or other relevant operations are executed to further verify the presence or absence of the element with a significantly high degree of confidence.

It is important to emphasise that the bloom filter's design is intentionally engineered to prioritise query efficiency and conserve computational resources. Consequently, the potential for false positives exists, implying that in certain instances, the filter may indicate the presence of an element that is, in reality, absent from the ledger. However, these occurrences are carefully managed by selecting appropriate parameters and monitoring the trade-off between accuracy and resource optimisation.

The impact of bloom filter

By employing bloom filters in this manner, the VeChainThor blockchain significantly reduces the computational burden associated with address and block lookup operations, resulting in improved responsiveness and heightened scalability. This, in turn, positively impacts the overall user experience and facilitates seamless integration with various applications and services built on the blockchain platform.

// 1 - Get best value of k (bits per key)

const m = 100; // Number of hash functions used in the bloom filter,
const k = BloomFilter.computeBestHashFunctionsQuantity(m);
console.log(k);

// 2 - Create an empty bloom filter with 14 bits per key.

const bloomGenerator = BloomFilter.of();

// 3 - Add number from 0 to 99 to the bloom generator

for (let i = 0; i < 100; i++) {
    bloomGenerator.add(HexUInt.of(i).bytes);
}

// 4 - Create the filter

const bloomFilter = bloomGenerator.build(k, m);

// Positive case (number from 0 to 99 must be present in the bloom filter)
for (let i = 0; i < 100; i++) {
    const inFilter = bloomFilter.contains(HexUInt.of(i).bytes); // All true
    expect(inFilter).toBeTruthy();
}

// Negative case (number from 100 must not be present in the bloom filter)
const notInFilter = bloomFilter.contains(HexUInt.of(100).bytes); // False
expect(notInFilter).toBeFalsy();
PreviousAccountsNextCertificates

Last updated 1 month ago

Was this helpful?