Skip to content

Commit af7a967

Browse files
committed
udpates after discussion
1 parent 73d09b2 commit af7a967

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

designdocs/batched_messages.md

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ This design document describes batched messages and APIs for sending and retriev
1616
In order to reduce costs for announcers of messages on-chain as well as reduce network congestion, announcers collate messages into batches of the same type of message and announce the batch location on-chain, instead of announcing each individual message.
1717

1818
## Goals and Non-Goals
19-
This specifies how batches are to be announced on chain: what is required and how a batch may be partially verified based on on-chain information.
19+
This specifies how batches are to be announced on chain; what is required and how a batch may be partially verified based on on-chain information.
2020

21-
This document does not describe the messages that are supported for batch announcements. Please see the [DSNP Specification](https://spec.dsnp.org/).
21+
This document does not describe the types of DSNP messages that would be in batch announcements. Batch announcements must reference a schema through its ID number. A schema may or may not describe a DSNP message.
2222

23-
This document does not discuss validation of batch file format located at the URL in the announcement, since
24-
the file format cannot be verified on-chain. For details about batch file format, see [DSNP Spec: Batch Publications](https://spec.dsnp.org/DSNP/BatchPublications).
23+
This document does not discuss validation of batch file format located at the URI in the announcement, since
24+
the file format cannot be verified on-chain. For details about batch files themselves, see [DSNP Spec: Batch Publications](https://spec.dsnp.org/DSNP/BatchPublications).
2525

2626
## Proposal
2727
* All names are placeholders and may be changed.
28+
* Types may change as needed during implementation phase
2829
* Errors in the extrinsic(s) must have different, reasonably-named error enums for each type of error for ease of debugging.
2930

3031
### Constants
@@ -37,45 +38,41 @@ other formats are being considered.
3738

3839
### Types
3940
* `BatchAnnouncementParams<T:Config>`: generic
40-
* `batch_url`:`Vec<u8>` the URL of the batch file. Must be an IPFS [CIDv1](https://github.com/multiformats/cid/) URL. Accepted codec, algorithm, and base are to be determined.
41+
* `batch_uri`:`Vec<u8>` the URI of the batch file. Must be an IPFS [CIDv1](https://github.com/multiformats/cid/) URI. Accepted codec, algorithm, and base are to be determined.
4142
* `message_schema_id`: `SchemaId` the schema id for the messages in this batch. The `schema_id` must refer to schemas used for batching only.
4243
* `file_size`: `usize`, the size of the batch file, used to determine message fee as well as to let consumers know what size files to expect. Must be &gt;= the minimum possible DSNP batch file size.
4344
* `file_format`: `BatchFormat`, indicator of the file format of the batch file.
44-
* `msa_id`: `MsaId`, the id to use for the batch. Must exist and be active. Must be owned by origin (sender).
4545

46-
The file hash is not included separately. Since the `batch_url` uses CIDv1 specification, the file hash is already included.
46+
The file hash is not included separately. Since the `batch_uri` uses CIDv1 specification, the file hash is already included.
4747

4848
* `BatchAnnouncement`: implements `BatchAnnouncementParams`, returned by `get_batches`
4949

50-
See the [implementation of paging in the messages pallet](https://github.com/LibertyDSNP/mrc/blob/main/common/primitives/src/messages.rs#L26-L58)
50+
See the [implementation of paging in the messages pallet](https://github.com/LibertyDSNP/mrc/blob/main/common/primitives/src/messages.rs#L26-L58) for comparison.
5151

5252
* `BatchAnnouncementOptions<T:Config>`
53-
* `msa_id`: `MsaId`, the announcer's MSA id. If 0, get all announcements
53+
* `msa_id`: `Option<MsaId>`, the announcer's MSA id. Pass None() to get all announcements.
5454
* `from_block`: `<T::BlockNumber>`, retrieve messages starting at the given block number (inclusive)
5555
* `to_block`: `<T::BlockNumber>`, retrieve messages ending at the given block number (inclusive)
5656
* `from_index`: `u32`, starting message index
5757
* `page_size`: `usize`, retrieve `page_size` messages at a time, up to configured `T::BatchPageSizeMax`. If 0, return `T::BatchPageSizeMax` results
5858

59-
6059
* `BatchAnnouncementResult`
6160
* `has_next`: `uint32`, current page number
6261
* `next_block`: `<T::BlockNumber>` starting block number of next page of results
6362
* `next_index`: `u32` starting index of next results in `next_block`
6463
* `results`: `Vec<BatchAnnouncement>`
6564

66-
6765
### Extrinsics
6866
#### announce_batch(origin, batch_announcement_params)
69-
Creates and posts a new batch announcement message on chain.
67+
Creates and posts a new batch announcement message on chain, using the batch message Schema Id. This Schema Id must already be registered and will need to be fetched by the extrinsic. The transaction fee is determined in part by the file size.
7068

7169
* **Parameters**
7270
* origin: required for all extrinsics, the caller/sender.
7371
* `batch_announcement_params`: `BatchAnnouncementParams`, the parameters to use in the batch announcement.
7472

75-
* **Event**: `Event::<T>::BatchAnnounced(schema_id file_size, file_hash, msa_id, signature)`
73+
* **Event**: `Event::<T>::BatchAnnounced(schema_id, msa_id, file_size, batch_uri)`
7674
* **Restrictions**:
77-
* origin must own `msa_id`
78-
* `msa_id` account must have capacity to post the transaction during the current epoch
75+
* origin's `msa_id` must have capacity to post the transaction during the current epoch
7976

8077
### Custom RPCs
8178

@@ -87,10 +84,26 @@ Retrieves paged batch announcements that have not been garbage-collected which m
8784

8885
* **Returns**
8986
* `None()` if no messages meet the criteria.
90-
* `Some(BoundedVec<BatchAnnouncement, page_size>)`, in descending block-transaction order
87+
* `Some(Vec<BatchAnnouncement>)`, in descending block-transaction order
88+
89+
90+
### Benefits and Risks
91+
Please see [Batching Source Dependent Messages With Delegation](https://forums.projectliberty.io/t/04-batching-source-dependent-messages-with-delegation/216), for discussion about the benefits of announcing batch files on chain rather than all types of user-created messages.
92+
93+
One risk is that providers on MRC could simply register a new schema and announce batches "unofficially". We have not decided whether to let everyone with enough token to register a schema. Other MRC participants would need to first learn about and evaluate new schemas, then update their software to consume a new message type.
94+
95+
Another risk, mentioned in the Alternatives and Rationale section, is that providers would announce smaller batches than the actual batch file sizes. Earnest MRC participants, such as indexers, will quickly learn this announcer is not reliable and ignore batches marked with that announcer's MsaId.
96+
97+
### Alternatives and Rationale
98+
We discussed whether a batch message itself can be delegated, but this would have complicated things and we cannot come up with a use case for delegating batches. It also violates the idea of users delegating explicitly to every provider that performs a service for them, which is a fundamental value we want to apply to the network.
99+
100+
We discussed whether to allow URLs such as HTTP/HTTPS or other URLs and instead opted for content-addressable URIs (CIDv1) which can be resolved by some other service. This allows us to put the file hash directly into a URI. It reduces message storage because we don't have to include both a URL and a file hash. A file hash is necessary as a check against file tampering.
101+
102+
We revisited the idea of whether it really is necessary to include a file size. We will be charging a premium for larger files, however, there will be per-byte discount for larger files in order to create an incentive for posting batches while reducing the incentive for announcers to allow spam. Although the processing and downloading time for enormous files also serves as a disincentive for spam, we feel it would not be sufficient.
103+
104+
Despite the fact that announcers can lie abut the file size, the file_size parameter also serves as an on-chain declaration that not only allows consumers of batches to quickly discover if a batch announcer was honest, but the file requestor can know in advance when to stop requesting data.
91105

92106
### Glossary
93107
* *IPFS* [InterPlanetary File System](https://docs.ipfs.io/), a decentralized file system for building the next generation of the internet
94108
* *CID* [Content IDentifier](https://github.com/multiformats/cid/), Self-describing content-addressed identifiers for distributed systems
95109
* *MsaId* [Message Source Account ID](https://github.com/LibertyDSNP/mrc/blob/main/designdocs/ACCOUNTS.md) an identifier for a MSA.
96-
*

0 commit comments

Comments
 (0)