npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@bcoders.gr/eth-provider

v1.0.2

Published

High-Performance IPC Ethereum Provider with Advanced Optimizations - Refactored for Better Performance

Downloads

12

Readme

High-Performance IPC Ethereum Provider v2.0

A highly optimized, modular IPC Ethereum provider with advanced performance features and comprehensive monitoring capabilities.

🚀 Performance Improvements (v2.0)

This refactored version delivers significant performance improvements through:

  • Modular Architecture: Split into focused, optimized components
  • Advanced Memory Management: Object pooling and efficient buffer operations
  • Intelligent Caching: LRU cache with TTL and automatic cleanup
  • Optimized JSON Parsing: Fast boundary detection with streaming support
  • Smart Batch Processing: Priority-based batching with deduplication
  • Comprehensive Metrics: Detailed performance monitoring and profiling

📦 Installation

npm install @bcoders.gr/eth-provider

🔧 Quick Start

import { IPCProvider } from '@bcoders.gr/eth-provider';

const provider = new IPCProvider('/path/to/geth.ipc', {
  // Performance options
  cacheEnabled: true,
  batchRequests: true,
  poolSize: 100,
  
  // Cache configuration
  cacheSize: 1000,
  cacheTTL: 5000,
  
  // Batch configuration
  batchSize: 10,
  batchTimeout: 10,
  
  // Connection options
  requestTimeout: 30000,
  autoReconnect: true,
  maxRetries: 3
});

await provider.connect();

// Use standard Ethereum JSON-RPC methods
const balance = await provider.getBalance('0x...');
const blockNumber = await provider.getBlockNumber();
const receipt = await provider.getTransactionReceipt('0x...');

// Get performance statistics
const stats = provider.getStats();
provider.printStats();

await provider.disconnect();

🏗️ Modular Architecture

Core Components

  • ConnectionManager: Optimized IPC connection handling with auto-reconnection
  • CacheManager: High-performance LRU cache with TTL support
  • JSONParser: Fast streaming JSON parser with boundary detection
  • BatchProcessor: Intelligent request batching with priority queues
  • MetricsManager: Comprehensive performance monitoring
  • RequestPool: Memory-efficient object pooling

Individual Component Usage

import { 
  ConnectionManager, 
  CacheManager, 
  JSONParser,
  BatchProcessor,
  MetricsManager,
  RequestPool 
} from '@bcoders.gr/provider';

// Use components individually for custom implementations
const cache = new CacheManager({ maxSize: 500, defaultTTL: 3000 });
const metrics = new MetricsManager({ enabled: true });

⚡ Performance Features

1. Object Pooling

Reduces garbage collection overhead by reusing request objects:

const provider = new IPCProvider(ipcPath, {
  poolSize: 100,        // Initial pool size
  maxPoolSize: 500      // Maximum pool growth
});

2. Intelligent Caching

Caches read-only method responses with automatic expiration:

const provider = new IPCProvider(ipcPath, {
  cacheEnabled: true,
  cacheSize: 1000,      // Max cached items
  cacheTTL: 5000        // Cache TTL in ms
});

3. Batch Processing

Groups requests for better throughput:

const provider = new IPCProvider(ipcPath, {
  batchRequests: true,
  batchSize: 10,        // Requests per batch
  batchTimeout: 10      // Max wait time (ms)
});

4. Advanced Metrics

Comprehensive performance monitoring:

const stats = provider.getStats();
console.log(stats.metrics.derived.requestsPerSecond);
console.log(stats.cache.hitRatio);
console.log(stats.pool.efficiency);

// Print detailed summary
provider.printStats();

📊 Performance Benchmarks

Run the included benchmarks to see performance improvements:

npm run benchmark

Expected improvements over v1.x:

  • Object Pooling: 30-50% reduction in allocation overhead
  • JSON Parsing: 40-60% faster for newline-separated responses
  • Caching: 80-95% faster for repeated read-only calls
  • Memory Usage: 20-40% reduction in heap usage

🔧 Configuration Options

const provider = new IPCProvider(ipcPath, {
  // Connection settings
  requestTimeout: 30000,
  autoReconnect: true,
  maxRetries: 3,
  retryDelay: 1000,
  maxRetryDelay: 10000,
  backoffMultiplier: 2,
  
  // Performance settings
  bufferSize: 2 * 1024 * 1024,  // 2MB buffer
  poolSize: 100,
  maxPoolSize: 500,
  
  // Cache settings
  cacheEnabled: true,
  cacheSize: 1000,
  cacheTTL: 5000,
  
  // Batch settings
  batchRequests: true,
  batchSize: 10,
  batchTimeout: 10,
  deduplicationEnabled: true,
  
  // Metrics settings
  metricsEnabled: true,
  trackResponseTimes: true,
  trackMemoryUsage: true,
  
  // Logging
  logger: console
});

📈 Monitoring & Metrics

Real-time Statistics

const stats = provider.getStats();

// Connection metrics
console.log(stats.connection.connected);
console.log(stats.metrics.connection.uptime);

// Performance metrics
console.log(stats.metrics.derived.requestsPerSecond);
console.log(stats.metrics.derived.successRate);
console.log(stats.metrics.responses.avgTime);

// Cache performance
console.log(stats.cache.hitRatio);
console.log(stats.cache.size);

// Memory usage
console.log(stats.pool.totalPoolSize);
console.log(stats.parser.bufferSize);

Method-specific Metrics

const metrics = provider.getStats().metrics;

// Top methods by usage
const topMethods = metrics.methods;
console.log(topMethods['eth_blockNumber']);

// Recent errors
console.log(metrics.recentErrors);

🛠️ Advanced Usage

Custom Component Configuration

// Advanced cache configuration
const provider = new IPCProvider(ipcPath, {
  cacheEnabled: true,
  cacheSize: 2000,
  cacheTTL: 10000,
  cleanupInterval: 60000  // Cache cleanup frequency
});

// Advanced batch configuration
const provider = new IPCProvider(ipcPath, {
  batchRequests: true,
  batchSize: 20,
  batchTimeout: 5,
  maxConcurrentBatches: 10,
  deduplicationEnabled: true
});

Health Monitoring

// Check provider health
const health = await provider.healthCheck();
console.log(health.status);      // 'healthy' or 'unhealthy'
console.log(health.latency);     // Response latency
console.log(health.connected);   // Connection status

🔄 Migration from v1.x

The v2.0 API is largely backward compatible:

// v1.x code continues to work
const provider = new IPCProvider('/path/to/geth.ipc');
await provider.connect();
const balance = await provider.getBalance('0x...');

// v2.0 adds new capabilities
const stats = provider.getStats();  // New in v2.0
provider.printStats();              // New in v2.0

🧪 Testing

# Validate all modules
npm run check

# Run performance benchmarks
npm run benchmark

# Full validation
npm run validate

📝 API Reference

Core Methods

  • connect() - Connect to IPC endpoint
  • disconnect() - Disconnect and cleanup
  • request(method, params) - Make JSON-RPC request
  • getStats() - Get comprehensive statistics
  • printStats() - Print performance summary

Ethereum Methods

  • getBalance(address, blockTag)
  • getBlockNumber()
  • getGasPrice()
  • getTransactionCount(address, blockTag)
  • sendTransaction(txObject)
  • sendRawTransaction(signedTx)
  • getTransactionReceipt(txHash)
  • call(to, data, blockTag)
  • estimateGas(txObject)

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and benchmarks
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🔗 Links


Performance-optimized for production Ethereum applications 🚀