Skip to content

Commit 293affb

Browse files
committed
fip-0107: commit to API option 2 - implement new v2 APIs
1 parent ff0c73e commit 293affb

File tree

1 file changed

+41
-11
lines changed

1 file changed

+41
-11
lines changed

FIPS/fip-0107.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -186,13 +186,43 @@ type ActorEvent struct {
186186
}
187187
```
188188

189-
#### New APIs for Accessing Implicit Messages
189+
#### v2 APIs for Accessing Implicit Messages
190190

191-
Since existing list-based APIs cannot return implicit messages without breaking compatibility, new mechanisms are needed:
191+
Since existing list-based APIs cannot return implicit messages without breaking compatibility, v2 APIs will provide flexible access to implicit messages through an options parameter.
192192

193-
**Option 1 - New API**: `ChainGetAllParentReceipts` - returns all receipts including those for implicit messages. This API would return the same results as `ChainGetParentReceipts` before activation of this FIP, but would include additional receipts for implicit messages after activation.
193+
As of the time of writing, development has begun on the Lotus v2 APIs. It is expected this will eventually lead to extension of [FRC-0104 Common Node APIs](https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0104.md). This opportunity will be used to introduce an options object that allows fine-grained control over implicit message inclusion.
194194

195-
**Option 2 - v2 API**: As of the time of writing, development has begun on the Lotus v2 APIs. It is expected this will eventually lead to extension of [FRC-0104 Common Node APIs](https://github.com/filecoin-project/FIPs/blob/master/FRCs/frc-0104.md). This opportunity could be used to break APIs and introduce an options object that would allow optional inclusion of implicit messages. e.g. `ChainGetParentReceipts` could add a new paramter that would change the returned list to prevent filtering: `{ includeImplicits: true }`.
195+
Relevant v2 APIs will accept an optional options parameter with an `implicits` field that controls how implicit messages are handled:
196+
197+
```go
198+
type ImplicitOption string
199+
200+
const (
201+
ImplicitIgnore ImplicitOption = "ignore" // Returns only explicit messages (default)
202+
ImplicitInclude ImplicitOption = "include" // Returns both explicit and implicit messages
203+
ImplicitOnly ImplicitOption = "only" // Returns only implicit messages
204+
)
205+
206+
// MessageOptions provides fine-grained control over message or receipt retrieval, this will be
207+
// optional for APIs that accept it. Currently only implicits is defined but this may be expanded
208+
// in the future.
209+
type MessageOptions struct {
210+
Implicits ImplicitOption `json:"implicits,omitempty"` // defaults to "ignore" for backward compatibility
211+
}
212+
```
213+
214+
- `"ignore"` (default): Returns only explicit messages or their receipts, maintaining compatibility with v1 behavior
215+
- `"include"`: Returns both explicit and implicit messages or their receipts
216+
- `"only"`: Returns only implicit messages or their receipts
217+
218+
Example usage:
219+
- `ChainGetParentReceipts(blockCid, { "implicits": "include"})` - returns all receipts
220+
- `ChainGetParentMessages(tsk, { "implicits": "only"})` - returns only implicit messages
221+
- `ChainGetParentMessages(blockCid, { "implicits": "ignore"})` - returns only explicit messages (default)
222+
223+
Initially the focus will be on APIs that access receipts or may logically access messages via receipts: `ChainGetParentReceipts` and `ChainGetParentMessages`. `ChainGetMessagesInTipset` is excluded initially as it currently loads messages directly from a tipset, however future consideration could be given to adding implicit messages to the returned list as well.
224+
225+
This design provides maximum flexibility while maintaining backward compatibility and enabling specific use cases like monitoring only system operations.
196226

197227
## Design Rationale
198228

@@ -202,7 +232,7 @@ This design was chosen to minimise disruption to existing systems while providin
202232
2. **Execution ordering**: Maintains consistency with current execution semantics.
203233
3. **Message specification**: Uses the existing Lotus implicit message format as a stable basis for all node implementations.
204234
4. **Gas limit approach**: Maintains existing execution patterns while clarifying that implicit messages operate outside block gas limit constraints. This ensures system operations can complete successfully regardless of user message activity or network congestion.
205-
5. **API compatibility**: Excludes implicit messages from most APIs by default to avoid breaking existing integrations while allowing direct access when needed.
235+
5. **API compatibility**: Excludes implicit messages from most APIs by default to avoid breaking existing integrations while providing a clear path forward with v2 APIs for accessing implicit messages.
206236

207237
### Storage Efficiency Assessment
208238

@@ -233,7 +263,7 @@ This change introduces several backwards incompatibilities:
233263
1. **Receipt Structure Change**: The `MessageReceipt` structure modification requires updates to all code that directly accesses receipt fields; this change will take effect at the next epoch after the activation epoch of this FIP
234264
2. **Message/Receipt Count Mismatch**: Code assuming `length(deduped parent messages) == length(receipts)` will break and must be updated to either:
235265
- Use APIs that maintain the old behaviour by filtering out implicit messages
236-
- Adapt to use the new `ChainGetAllParentReceipts` (or alternative v2) API when access to all receipts is needed
266+
- Adapt to use v2 APIs with appropriate options when access to all receipts is needed
237267

238268
### API Migration Guide
239269

@@ -242,7 +272,7 @@ Applications should adapt as follows:
242272
1. **For transaction enumeration**: Continue using existing APIs which will maintain backward compatibility
243273
2. **For complete chain analysis**:
244274
- Monitor `GetActorEventsRaw` for system events (check `implicit` field)
245-
- Use new `ChainGetAllParentReceipts` (or alternative v2) API when available
275+
- Use v2 APIs with `{implicits: "include"}` option when available
246276
- Query implicit messages directly by CID when needed
247277
3. **For Ethereum compatibility**: No changes needed - existing behaviour is maintained
248278
4. **For receipt processing**: Update code to handle both old and new receipt formats with null checks on new fields
@@ -309,7 +339,7 @@ For index-based APIs like `eth_getTransactionByBlockHashAndIndex`:
309339

310340
Implicit messages can be discovered through:
311341
1. **Event-based discovery**: Events from `GetActorEventsRaw` include the emitter's actor ID and message CID
312-
2. **Receipt-based discovery**: Using `ChainGetAllParentReceipts` (or alternative v2 API) to iterate all receipts
342+
2. **Receipt-based discovery**: Using v2 APIs with `{implicits: "include"}` or `{implicits: "only"}` to iterate receipts
313343
3. **Direct query**: If the CID is known, query directly via `ChainGetMessage`
314344

315345
**Important**: Not all implicit messages emit events. Reward messages currently emit no events, and cron messages only emit events for specific operations (e.g., sector terminations). Applications requiring complete implicit message visibility must use receipt-based discovery.
@@ -320,7 +350,7 @@ Tools requiring implicit message processing should:
320350
1. Monitor `GetActorEventsRaw` for system events
321351
2. Use the message CID from receipts to query message details
322352
3. Check the `implicit` field on events to identify system-generated events
323-
4. Use `ChainGetAllParentReceipts` for complete message enumeration when available
353+
4. Use v2 APIs with appropriate `implicits` option for complete message enumeration when available
324354

325355
## Test Cases
326356

@@ -363,7 +393,7 @@ The following test scenarios should be implemented:
363393
- Verify Ethereum APIs exclude implicit messages from counts and lists
364394
- Verify direct query APIs return implicit messages when queried by CID/hash
365395
- Verify `eth_getLogs` excludes events from implicit messages
366-
- Test suggested `ChainGetAllParentReceipts` or v2 variant returns all receipts
396+
- Test v2 APIs with different `implicits` options
367397

368398
## Security Considerations
369399

@@ -429,7 +459,7 @@ Implementation requires changes to:
429459
- Update message retrieval methods to filter implicit messages by default
430460
- Update receipt retrieval methods to filter implicit message receipts
431461
- Add `implicit` field to `ActorEvent` type
432-
- Implement suggested `ChainGetAllParentReceipts` API
462+
- Implement v2 APIs with options parameter supporting `implicits` enum
433463
- Update Ethereum APIs to maintain backward compatibility
434464

435465
4. **FVM changes**:

0 commit comments

Comments
 (0)