Assessment reports>Polyhedra zk light client on LayerZero>Discussion>Batch update gas optimization

Batch update gas optimization via aggregation circuit

The batch update function batchUpdateFpHash in ZkBridgeOracle.sol expects as input a proof for each hash in the batch. All these proofs are verified separately by the verifier contract.

function batchUpdateFpHash(uint16[] calldata _sourceChainIds, bytes32[] calldata _blockHashes, bytes[] calldata zkMptProofs, address[] calldata _userApplications) external {
    require(address(zkMptValidator)!=address(0),"ZkBridgeOracle:Not set zkMptValidator");
    require(_sourceChainIds.length == _blockHashes.length, "ZkBridgeOracle:Parameter lengths must be the same");
    require(_sourceChainIds.length == zkMptProofs.length, "ZkBridgeOracle:Parameter lengths must be the same");
    require(_sourceChainIds.length == _userApplications.length, "ZkBridgeOracle:Parameter lengths must be the same");
    IZKMptValidator.Receipt memory receipt;
    for (uint256 i = 0; i < _sourceChainIds.length; i++) {
        receipt = zkMptValidator.validateMPT(zkMptProofs[i]);
        _updateHash(_sourceChainIds[i], _blockHashes[i], receipt.receiptHash, receipt.logsHash, receipt.logsHash, _userApplications[i]);
    }
}

Implementing an aggregation circuit in the future for these proofs to roll up a number of them into a single verification could help greatly reduce the cost of batch updates.

Polyhedra has acknowledged this optimization and plan to implement it in a future update.

Zellic © 2025Back to top ↑