# A sharded mempool for PeerDAS
Background: https://notes.ethereum.org/@dankrad/BkJMU8d0R
## Whitelisted addresses
Suggested whitelist for sending blobs to sharded mempool:
- any address that has sent more than `MIN_BLOBS` blob transactions in the last 24 hours, included on chain
- any address that has burned more then `MIN_BURN` ETH (via fees or by sending it to the null address)
The first condition ensures that all rollups that post blob transactions regularly can continue to do so. The second condition allows new addresses to be bootstrapped into this pool.
(This is opinionated in that it mostly considers rollup use cases. This will make it more difficult for applications that only occasionally use blobs, e.g. NFT projects)
## ExecutionEngine endpoints
We add two new endpoints to the execution engine:
* `engine_getBlobSendingAddresses` -- returns list of addresses whitelisted for the blob mempool
* `engine_newBlobsAvailable` -- sets a list of blobs available for the execution engine to include in a block
## Transaction Sample
```python
class TransactionSample:
index: ColumnIndex # Index of column in extended matrix
column: List[Cell, MAX_BLOB_COMMITMENTS_PER_BLOCK]
kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
kzg_proofs: List[KZGProof, MAX_BLOB_COMMITMENTS_PER_BLOCK]
# Signature using EL address -- for the sample NOT the transaction
y_parity: boolean
r: uint256
s: uint256
```
## BlobAvailabilityVote
```python
TARGET_BLOB_AVAILABILITY_ATTESTERS = 16
```
```python
class BlobAvailabilityVote:
availability_voter_index: ValidatorIndex
kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
selection_proof: BLSSignature
signature: BLSSignature
def get_slot_signature(state: BeaconState, slot: Slot, privkey: int) -> BLSSignature:
domain = get_domain(state, DOMAIN_SELECTION_PROOF, compute_epoch_at_slot(slot))
signing_root = compute_signing_root(slot, domain)
return bls.Sign(privkey, signing_root)
def is_blob_availability_attester(state: BeaconState, slot: Slot, index: CommitteeIndex, slot_signature: BLSSignature) -> bool:
committee = get_active_validator_indices(state, get_epoch_for_slot(slot)) // SOTS_PER_EPOCH
modulo = max(1, len(committee) // TARGET_BLOB_AVAILABILITY_ATTESTERS)
return bytes_to_uint64(hash(slot_signature)[0:8]) % modulo == 0
```
## Functionality
* `TransactionSample` objects are sent on the same sample subnets used for DAS
* Every node locally determines whether blobs are available using the subnets it is subscribed to
* Some nodes also send votes on which blobs they see as available:
* A validators is an availability attester if `is_blob_availability_attester` returns true
* Validators that are availability attesters send `BlobAvailabilityVote` whenever they have determined that one or several blobs are valid
* To determine whether a blob transaction is available, a node building a block verifies
* It is locally available (all the blob samples are in the subnets the node is listening to)
* Enough blob availability attesters have attested to its availability. The suggested threshold is `TARGET_BLOB_AVAILABILITY_ATTESTERS // 2`, but nodes can vary this threshold can be locally varied (e.g. when many validators are offline)
* Whenever blobs become locally available, the beacon node calls the `engine_newBlobsAvailable` endpoint in order to notify the execution client
# Rationale
## Address whitelisting
In the current mempool design, every transaction comes with an implicit guarantee that the bandwidth spent propagating it is not wasted, because we verify that transactions can be included and the sender address is able to pay the fee.
However, when decoupling data from the transaction, a malicious actor has a number of ways of wasting bandwidth:
- sending a transaction without sending the corresponding data
- sending the data for a transaction without the transaction
In these cases, there is no guarantee that any payment (or even a risk of payment) exists, so we need some other mechanism of ensuring that bandwidth can't be limited.
Therefore we need to put some reasonable limit on the number of addresses that can add blob tx to the mempool.