@Luca @Kubuxu

# 🌍 Background

PoRep challenges are generated outside Snark Circuits and passed as inputs at verification time. These inputs need to be generated on the spot in order for verification to happen.

With Non Interactive PoRep, the number of challenges is multiplied by a minimum of 8x in order to reach 80 bits of security (wrt to the current 10 we have in PoRep).

These days, 80 bits of security is considered a reasonable parameter, even if we could want to get up to 128 (which would translate in a 12.8x overhead wrt status quo).

## 📋 Gas cost Analysis: NI-PoRep Vs status quo

We analyze the concrete impact of NI-PoRep proving overhead on gas costs for SPs.

Some aspects to take into account:

- NI-PoRep removes the
`PreCommit`

step. This means that`PreCommit`

gas costs are equal to 0 - We assume we are using SnarkPack to aggregate proofs.
- Note that today Snarkpack is not really used since, due to how gas is counted for
`ProveCommitAggregate`

, it is more convenient for SPs to submit single proofs rather than aggregated ones. An overview of this aspect and a proposal for mitigations can be found in Separating proof validation from sector activation (note that this is going to be fixed soon) - We consider gas costs of a given number of sectors, which proofs get aggregated
- Note that this analysis only considers gas costs associated with verifying proofs on both the Interactive and Non Interactive scenario. We are not considering proving overhead (which quite easy to estimate, and correspond to ~8x wrt the status quo)

### Useful Resources

- is the reference doc for proof fees and gas costs.
- Single proof gas: 49299973 ~ 49M gas units
- Batch Balancer: 5% of Single proof gas (~2.5M gas units)
- Proof Submit Charge gas: 34721049 ~34M gas units

Note that this doc was put together by Kuba, referring to the FVM price list, which was set by empirically testing verification times.

We'll be using the following values from the aforementioned doc

For aggregated proof, gas costs are as follows:

Single Circuit Gas cost |

449900 |

Number of circuits aggregated | Number of Current PoRep aggregated | Gas Cost |

> 32 = 2^5 | 4 | 103994170 |

> 64 = 2^6 | 7 | 112356810 |

>128 = 2^7 | 13 | 122912610 |

>256 = 2^8 | 26 | 137559930 |

> 512 = 2^9 | 52 | 162039100 |

> 1024 = 2^10 | 103 | 210960780 |

> 2048 = 2^11 | 205 | 318351180 |

> 4096 = 2^12 | 410 | 528274980 |

This means that if we have a number of circuit N which is not a power of two, the total gas cost will be the sub between the gas cost corresponding to $2^{\lfloor{log_2(N)}\rfloor}$ and 449900*(N - $2^{\lfloor{log_2(N)}\rfloor}$)

Example: aggregating 34 circuits costs 103994170+ 2*449900, given that $\lfloor log_2(34)\rfloor = 5$

**Starboard**

## Single Sector

We compare here gas costs for single sectors, taking into account status quo gas costs and costs for single NI-PoRep sector

C**urrent single sector, no Snarkpack aggregation (not currently used)**

`PreCommit`

~53 M gas units [approximation obtained by taking*GasUsage/MessageCount*in**Starboard**- Snark Verification (10 single snark proofs) at ProveCommit takes ~34M gas units
- See
*Proof Submit Charge gas*in

**NI-PoRep Sectors, aggregating sector proofs w/ Snarkpack**

- No
`PreCommit`

- Snark Verification (80 single snark proofs) at ProveCommit takes ~114M gas units assuming the 80 snark proofs are aggregated with SnarkPack

**Outcome**

- If we consider proof verification only, NI-PoRep proof verification is ~3.5 times more expensive than current PoRep proof verification (114M Vs 34M gas units ⇒ difference of 80M gas units).
- If we consider total gas costs, given that NI-PoRep removes
`PreCommit`

(and associated gas costs), the difference is goes down to 27M gas units (114M Vs (34+53)M gas units)

## Aggregated Sectors

Here we compare gas costs associated with aggregating proofs for multiple sectors. We consider an example of 6 sectors aggregated. Note that differences between interactive and non interactive case would decrease when the number of aggregated sectors increases.

**Current Sectors**

`PreCommit`

~53M gas units per sector [approximation obtained by taking`GasUsage/MessageCount`

in**Starboard**- Snark verification of the aggregation of 6 current sectors (6*10 snark proofs) gives 17M gas units per sector (without batch balancer).
- Batch balancer is 5% of Single proof gas, which is the 5% of ~49M, resulting in ~2.5M gas units

**NI-PoRep Sectors**

- No
`PreCommit`

- Snark verification of the aggregation of 6 NI-PoRep sectors (6*8*10 snark proofs), gives a cost of 26M gas per sector.

**Outcome**

- If we consider proof verification only, NI-PoRep proof verification when aggregating 6 sectors is 9M gas units more expensive per sector (~1.5x current single proof verification costs).
- If we consider total gas costs, given that NI-PoRep removes
`PreCommit`

(and associated gas costs), then current sectors are 2.5x more expensive than NI-PoRep sectors (53M + 17M gas units for current sectors, 26M gas units for NI-PoRep sectors).