# BlsBn254 is not available in certain chains due to hardcoded gas limit

Hardcoded 120k gas for BN254 pairing precompile breaks BLS signature verification on chains like ZKSync where pairing costs 160k.

- Payout: Audit contest
- Severity: medium
- Program: Symbiotic Relay
- Found by: 0x73696d616f
- Disclosed: 2025-06-18
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-06-symbiotic-relay-judging/issues/422
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-06-symbiotic-relay%3AM-6
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:evm tech:solidity technique:source-review vuln:dos vuln:misconfiguration

**Target:** SigBlsBn254.sol BLS signature verification library
**Root cause:** SigBlsBn254.verify passes a hardcoded PAIRING_CHECK_GAS_LIMIT of 120_000 to BN254.safePairing's staticcall, assuming EIP-1108 pricing (34000*k+45000). Chains like ZKSync V28 price EcPairing at 80000*k, so k=2 needs 160k gas and the staticcall always fails.
**Steps:**
1. Deploy test contract on ZKSync Era mainnet calling staticcall(pairingGas, 8, input, 0x180, out, 0x20) with a valid 12-word pairing input
2. Start pairingGas at 120_000 and increment; observe success=false and out[0]=0
3. At ~161_000 gas, success=true and out[0]=1, confirming ZKSync's 80000*k cost
4. Conclude SigBlsBn254.verify's hardcoded 120_000 always reverts/fails on ZKSync
**How found:** Noticed the hardcoded PAIRING_CHECK_GAS_LIMIT constant derived from EIP-1108 and reasoned that precompile gas costs vary by chain; checked ZKSync's ZIP-11 V28 EcPairing.yul source showing 80000*k pricing, then empirically confirmed on mainnet by binary-searching pairingGas.
**Insight:** When a contract hardcodes a gas stipend for a precompile staticcall, check the target chain's actual precompile pricing (e.g. ZKSync ZIP-11, L2 forks) rather than assuming EIP-1108; a staticcall with insufficient gas silently returns false, which can be mistaken for a signature failure.

## Proof of concept (copied exactly from the original report)

**Test contract calling EcPairing precompile with configurable gas**

```
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

contract Test {

    event Cost(uint256);
    event Out(bool, uint256);

    function test (uint256[12] memory input, uint256 pairingGas) public {
        (uint256 gasBefore, uint256 gasAfter, bool success, uint256 out) = verify(input, pairingGas);
        emit Cost(gasBefore - gasAfter);
        emit Out(success, out);
    }

    function verify (uint256[12] memory input, uint256 pairingGas) public view returns (uint256, uint256, bool, uint256) {
        uint256[1] memory out;
        bool success;

        uint256 gasBefore = gasleft();
        // solium-disable-next-line security/no-inline-assembly
        assembly {
            success := staticcall(pairingGas, 8, input, mul(12, 0x20), out, 0x20)
        }
        uint256 gasAfter = gasleft();
        return (gasBefore, gasAfter, success, out[0]);
    }
}
```

**EcPairing input array for signature verification test**

```
[
17542794946843030738197687269502130768488764040084025709702018229683082027107, 21243454333462907454433938848788936660904069824545612138480299027504168819393, 11559732032986387107991004021392285783925812861821192530917403151452391805634, 10857046999023057135944570762232829481370756359578518086990519993285655852781, 17805874995975841540914202342111839520379459829704422454583296818431106115052, 13392588948715843804641432497768002650278120570034223513918757245338268106653, 6152845192698230377440204073057238033424791113774748884801148069022325658846, 13760496706863554449593094343798996929546352261485265365831743695186162488392, 10168917783125035928329339378130255896597415372015030444874307897081997728948, 15338339620195733484325031668011173090672215643291231872576243132177438055881, 10104509023153927337647655231628382133731833653099790728025758502925918550767, 13448048280709447326318302930315758447948705837394892676501482696723894570897
]
```

