Tutorial·9 min का पठन·Solingo द्वारा

EIP-4844 Blob Transactions — ये कैसे काम करते हैं

Blobs ने L2 economics बदल दी। यहाँ समझें कि ये क्या हैं, कैसे काम करते हैं, और कितना खर्च होता है।

# EIP-4844 Blob Transactions — ये कैसे काम करते हैं

Ethereum Cancun upgrade में सबसे बड़ा feature था EIP-4844, जिसे "proto-danksharding" भी कहते हैं। इससे Layer 2 rollups की cost 90% तक कम हो गई।

Problem क्या थी?

Rollups अपना transaction data Ethereum mainnet पर post करते हैं। यह data availability के लिए जरूरी है — अगर rollup disappear हो जाए, तो users अपने funds recover कर सकें।

// पहले: Rollup data calldata में

function submitBatch(bytes calldata rollupData) external {

// rollupData: 128 KB = ~1.8M gas (~$50-200)

}

Problem: Calldata permanent storage है। Rollups को सिर्फ कुछ weeks के लिए data चाहिए, लेकिन forever pay करना पड़ता है।

Blobs क्या हैं?

Blobs temporary data storage है। 1-2 weeks के बाद automatically delete हो जाते हैं।

Blob Format

1 blob = 4096 field elements (32 bytes each) = 128 KB

Max 6 blobs per block = 768 KB

हर blob KZG commitment के साथ आता है — cryptographic proof कि data सही है।

// Type 3 transaction (blob transaction)

struct BlobTx {

address to;

uint value;

bytes data;

bytes32[] blobVersionedHashes; // KZG commitments

}

Blob Lifecycle

1. Rollup creates blob data
  • Computes KZG commitment
  • Submits type-3 transaction
  • Blob stored for ~18 days
  • Auto-deleted (commitment stays forever)
  • Cost Comparison

    Calldata: 16 gas/byte × 128 KB = 2,048,000 gas
    

    Blob: ~120,000 gas (fixed cost)

    Savings: ~94% 🎉

    Real Impact: Arbitrum transaction fees गिरे $2 से $0.10 तक।

    Smart Contract में Blobs

    Contracts directly blobs read नहीं कर सकते। सिर्फ commitment verify कर सकते हैं:

    contract RollupContract {
    

    // BLOBHASH opcode — commitment hash return करता है

    function verifyBlob(uint index) public view returns (bytes32) {

    return blobhash(index); // Solidity 0.8.24+

    }

    // BLOBBASEFEE opcode — current blob gas price

    function getBlobFee() public view returns (uint) {

    return block.blobbasefee; // New field

    }

    }

    Blob Base Fee

    Calldata की तरह, blob fees dynamic हैं:

    Target: 3 blobs/block
    

    Max: 6 blobs/block

    If usage > 3: fee ↑ 12.5% per block

    If usage < 3: fee ↓ 12.5% per block

    function estimateBlobCost() external view returns (uint) {
    

    uint baseFee = block.blobbasefee;

    uint blobGasUsed = 131072; // Fixed per blob

    return baseFee * blobGasUsed;

    }

    Rollup Integration

    Optimism/Arbitrum जैसे rollups blobs इस तरह use करते हैं:

    // Off-chain: Batch transactions
    

    bytes memory batchData = compress(transactions);

    // Compute KZG commitment

    bytes32 commitment = kzg.commit(batchData);

    // Submit to L1

    rollupContract.submitBatch{value: blobFee}(

    commitment,

    stateRoot,

    blockNumber

    );

    L1 contract सिर्फ commitment store करता है। Full data blob में रहता है।

    Data Availability Proof

    contract OptimismPortal {
    

    mapping(bytes32 => bool) public commitments;

    function submitBatch(bytes32 commitment) external {

    // Verify blob commitment matches

    require(blobhash(0) == commitment, "Invalid blob");

    commitments[commitment] = true;

    }

    }

    Blob Data Retrieve कैसे करें?

    Contracts नहीं कर सकते, लेकिन off-chain clients कर सकते हैं:

    // eth_getBlobs RPC call
    

    const blobs = await provider.send('eth_getBlobs', [txHash]);

    // Decode blob data

    const rollupData = decodeBlobData(blobs[0]);

    यह 18 days के लिए available है। उसके बाद, rollup को अपने archives से serve करना होगा।

    Testing Blobs

    Foundry में blob transactions test करना:

    contract BlobTest is Test {
    

    function testBlobBaseFee() public {

    // Mock blob base fee

    vm.blobBaseFee(1 gwei);

    assertEq(block.blobbasefee, 1 gwei);

    }

    function testBlobHash() public {

    bytes32 expectedHash = keccak256("blob data");

    // Mock blob hash at index 0

    vm.blobhash(0, expectedHash);

    assertEq(blobhash(0), expectedHash);

    }

    }

    Economics

    Blob Fee Market

    Normal usage (2-3 blobs/block):
    
    • Blob fee: ~0.001-0.01 gwei
    • Cost per blob: ~$0.10-1.00

    Congestion (6 blobs/block):

    • Blob fee: 10+ gwei
    • Cost per blob: $10+

    Rollup Savings

    Before blobs:
    
    • Arbitrum tx: $2.00 (mostly DA cost)

    After blobs:

    • Arbitrum tx: $0.10 (20x cheaper)

    Security Considerations

    1. Data Availability Risk

    Blobs delete हो जाते हैं। Rollups को archive nodes चलाना जरूरी है:

    // ⚠️ Don't assume blob data forever available
    

    contract Rollup {

    // Store commitment on L1

    mapping(uint => bytes32) public batchCommitments;

    // Off-chain: Keep blob data in archive

    }

    2. KZG Trust Assumptions

    KZG commitments trusted setup पर depend करते हैं। Ethereum ने 140,000 participants से ceremony की — historically सबसे बड़ी।

    3. Blob Fee Spikes

    High demand में blob fees spike कर सकती हैं:

    function submitBatch() external payable {
    

    uint maxBlobFee = 100 gwei;

    require(block.blobbasefee <= maxBlobFee, "Blob fee too high");

    // Submit when economical

    }

    Future: Full Danksharding

    EIP-4844 proto-danksharding है। Full danksharding आएगा 2027-2028:

    Proto-danksharding: 6 blobs/block (0.75 MB/s)
    

    Full danksharding: 64+ blobs/block (8+ MB/s)

    यह L2 fees और भी कम करेगा — potentially <$0.01 per transaction।

    Conclusion

    EIP-4844 ने L2 economics fundamentally बदल दी। अगर आप rollup development या L2 integration कर रहे हैं, blobs समझना जरूरी है।

    Key Takeaways:

    • Blobs temporary storage = 90%+ savings
    • Contracts सिर्फ commitments verify करते हैं
    • Data 18 days के लिए available
    • Future में और ज्यादा throughput

    Roll-ups अब affordable हैं। यह Ethereum scaling का biggest breakthrough है। 🚀

    Practice में लगाने के लिए तैयार हैं?

    Solingo पर interactive exercises के साथ इन concepts को apply करें।

    मुफ्त में शुरू करें