Skip to content

Commit

Permalink
fix: aggregation spec to use height instead of size (#66)
Browse files Browse the repository at this point in the history
Renames `size` to `height` for `piece`/`aggregate` based on described in
storacha/data-segment#13

Note that:
- given `piece` and `aggregate` are both perfect binary trees, leaf
count of can be derived as `2 ** height`, and the size of the tree can
be derived by `leafCount * Node.Size` (32).
  • Loading branch information
vasco-santos authored Jul 18, 2023
1 parent d57aa96 commit b2ba739
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions w3-aggregation.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ A Storefront principal can invoke a capabilty to offer an aggregate that is read
"offer": { "/": "bafy...many-cars" }, /* dag-cbor CID with offer content */
"piece": {
"link": { "/": "commitment...aggregate-proof" },
"size": 10102020203013342343
"height": 4 /* height of the perfect binary tree for the aggregate */
} /* commitment proof for aggregate */
}
}],
Expand All @@ -141,14 +141,16 @@ A Storefront principal can invoke a capabilty to offer an aggregate that is read
}
```

Invoking `aggregate/offer` capability submits an aggregate to a broker service for inclusion in one or more Filecoin deals. The `nb.offer` field represents a "Ferry" aggregate offer that is ready for a Filecoin deal. Its value is the DAG-CBOR CID that refers to a "Ferry" offer. It encodes a dag-cbor block with an array of entries representing all the CAR files to include in the aggregated deal. This block MUST be included in the CAR file that transports the invocation. Its format is:
Invoking `aggregate/offer` capability submits an aggregate to a broker service for inclusion in one or more Filecoin deals. The `nb.piece` field represents the proof of the `piece` to be offered for the deal. It contains the proof CID `piece.link` together with the `piece.height` of the perfect binary tree computed for this aggregate. The `height` can be used to derive the leaf count (`2 ** height`), which can then be used to derive the `size` of the piece (`leafCount * Node.Size` where `Node.Size` is 32).

The `nb.offer` field represents a "Ferry" aggregate offer that is ready for a Filecoin deal. Its value is the DAG-CBOR CID that refers to a "Ferry" offer. It encodes a dag-cbor block with an array of entries representing all the pieces to include in the aggregated deal. This array MUST be sorted in the exact same order as they were used to compute the aggregate piece CID. This block MUST be included in the CAR file that transports the invocation. Its format is:

```json
/* offers block as PieceInfo type, encoded as DAG-JSON (for readability) */
/* offers block as an adapted PieceInfo type (with tree `height` instead of `size`), encoded as DAG-JSON (for readability) */
[
{
"link": { "/": "commitment...car0" }, /* COMMP CID */
"size": 110101,
"height": 110101, /* height of the perfect binary tree for the piece */
},
{
/* ... */
Expand Down Expand Up @@ -343,10 +345,13 @@ type AggregateOfferDetail struct {
type Offer [PieceInfo]
# Adapted from `PieceInfo` type in filecoin
# https://github.com/filecoin-project/go-state-types/blob/1e6cf0d47cdda75383ef036fc2725d1cf51dbde8/abi/piece.go#L47-L50
# Uses `height` field instead of `size`. `height` field can be used to derive `leafCount` and consequently `size`, while
# allowing the usage of smaller numbers instead of `bigint`.
type PieceInfo {
# Size in nodes. For BLS12-381 (capacity 254 bits), must be >= 16. (16 * 8 = 128)
size Int
# Height of the perfect binary tree for the piece
height Int
link Link
}
```
Expand Down

0 comments on commit b2ba739

Please sign in to comment.