Skip to content

Commit

Permalink
subscriptions: reinstate EventFilter::Any (#19807)
Browse files Browse the repository at this point in the history
## Description

Temporarily re-enable `EventFilter::Any` as it is still in use in some
places. This is a partial revert of #19617.

## Test plan

CI

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [x] Nodes (Validators and Full nodes): Temporarily re-enable
`EventFilter::Any` as a kind of event subscription filter. Note that
subscriptions are deprecated. This means they are not officially
supported, nor actively maintained.
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
amnn authored Oct 10, 2024
1 parent d46416f commit a49ca57
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
8 changes: 8 additions & 0 deletions crates/sui-core/src/authority.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4123,6 +4123,14 @@ impl AuthorityState {
limit,
descending,
)?,
// not using "_ =>" because we want to make sure we remember to add new variants here
EventFilter::Any(_) => {
return Err(SuiError::UserInputError {
error: UserInputError::Unsupported(
"'Any' queries are not supported by the fullnode.".to_string(),
),
})
}
};

// skip one event if exclusive cursor is provided,
Expand Down
2 changes: 1 addition & 1 deletion crates/sui-indexer/src/indexer_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,7 @@ impl IndexerReader {
// Processed above
unreachable!()
}
EventFilter::TimeRange { .. } => {
EventFilter::TimeRange { .. } | EventFilter::Any(_) => {
return Err(IndexerError::NotSupportedError(
"This type of EventFilter is not supported.".to_owned(),
));
Expand Down
5 changes: 5 additions & 0 deletions crates/sui-json-rpc-types/src/sui_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ fn try_into_byte(v: &Value) -> Option<u8> {
pub enum EventFilter {
/// Return all events.
All([Box<EventFilter>; 0]),

/// Return events that match any of the given filters. Only supported on event subscriptions.
Any(Vec<EventFilter>),

/// Query by sender address.
Sender(SuiAddress),
/// Return events emitted by the given transaction.
Expand Down Expand Up @@ -263,6 +267,7 @@ impl Filter<SuiEvent> for EventFilter {
let _scope = monitored_scope("EventFilter::matches");
match self {
EventFilter::All([]) => true,
EventFilter::Any(filters) => filters.iter().any(|f| f.matches(item)),
EventFilter::MoveEventType(event_type) => &item.type_ == event_type,
EventFilter::Sender(sender) => &item.sender == sender,
EventFilter::MoveModule { package, module } => {
Expand Down
16 changes: 16 additions & 0 deletions crates/sui-open-rpc/spec/openrpc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6120,6 +6120,22 @@
},
"additionalProperties": false
},
{
"description": "Return events that match any of the given filters. Only supported on event subscriptions.",
"type": "object",
"required": [
"Any"
],
"properties": {
"Any": {
"type": "array",
"items": {
"$ref": "#/components/schemas/EventFilter"
}
}
},
"additionalProperties": false
},
{
"description": "Query by sender address.",
"type": "object",
Expand Down

0 comments on commit a49ca57

Please sign in to comment.