You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: designdocs/batched_messages.md
+30-17Lines changed: 30 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -16,15 +16,16 @@ This design document describes batched messages and APIs for sending and retriev
16
16
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.
17
17
18
18
## 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.
20
20
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.
22
22
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).
25
25
26
26
## Proposal
27
27
* All names are placeholders and may be changed.
28
+
* Types may change as needed during implementation phase
28
29
* Errors in the extrinsic(s) must have different, reasonably-named error enums for each type of error for ease of debugging.
29
30
30
31
### Constants
@@ -37,45 +38,41 @@ other formats are being considered.
37
38
38
39
### Types
39
40
*`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.
41
42
*`message_schema_id`: `SchemaId` the schema id for the messages in this batch. The `schema_id` must refer to schemas used for batching only.
42
43
*`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 >= the minimum possible DSNP batch file size.
43
44
*`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).
45
45
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.
47
47
48
48
*`BatchAnnouncement`: implements `BatchAnnouncementParams`, returned by `get_batches`
49
49
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.
51
51
52
52
*`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.
54
54
*`from_block`: `<T::BlockNumber>`, retrieve messages starting at the given block number (inclusive)
55
55
*`to_block`: `<T::BlockNumber>`, retrieve messages ending at the given block number (inclusive)
56
56
*`from_index`: `u32`, starting message index
57
57
*`page_size`: `usize`, retrieve `page_size` messages at a time, up to configured `T::BatchPageSizeMax`. If 0, return `T::BatchPageSizeMax` results
58
58
59
-
60
59
*`BatchAnnouncementResult`
61
60
*`has_next`: `uint32`, current page number
62
61
*`next_block`: `<T::BlockNumber>` starting block number of next page of results
63
62
*`next_index`: `u32` starting index of next results in `next_block`
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.
70
68
71
69
***Parameters**
72
70
* origin: required for all extrinsics, the caller/sender.
73
71
*`batch_announcement_params`: `BatchAnnouncementParams`, the parameters to use in the batch announcement.
*`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
79
76
80
77
### Custom RPCs
81
78
@@ -87,10 +84,26 @@ Retrieves paged batch announcements that have not been garbage-collected which m
87
84
88
85
***Returns**
89
86
*`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.
91
105
92
106
### Glossary
93
107
**IPFS*[InterPlanetary File System](https://docs.ipfs.io/), a decentralized file system for building the next generation of the internet
94
108
**CID*[Content IDentifier](https://github.com/multiformats/cid/), Self-describing content-addressed identifiers for distributed systems
95
109
**MsaId*[Message Source Account ID](https://github.com/LibertyDSNP/mrc/blob/main/designdocs/ACCOUNTS.md) an identifier for a MSA.
0 commit comments