Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

events: Remove unsupported filters #19617

Merged
merged 3 commits into from
Sep 30, 2024
Merged

events: Remove unsupported filters #19617

merged 3 commits into from
Sep 30, 2024

Conversation

amnn
Copy link
Member

@amnn amnn commented Sep 30, 2024

Description

This PR removes EventFilters from JSON-RPC that aren't supported already by fullnode-backed JSON-RPC:

  • Combination filters (All, Any, Not, And, Or)
  • Package
  • EventField

These filters were, however, supported by the now-deprecated subscription system, so a question remains whether they are safe to remove.

Test plan

Manually tested, in particular All: [] support, which we do still need to keep as a way to get all filters (this was also added to the IndexerReader implementation):

sui$ cargo run --bin sui -- --force-regenesis \
  --with-indexer --with-faucet

...run for some time, so that some system events accumulate, then test that we get them from both the fullnode-backed JSONRPC and indexer-backed:

Fullnode:

curl -LX POST  "http://localhost:9000" \
        --header 'Content-Type: application/json' \
        --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "suix_queryEvents",
  "params": [
    {
      "All": []
    },
    null,
    50,
    true
  ]
}' | jq .

Indexer:

curl -LX POST  "http://localhost:9124" \
        --header 'Content-Type: application/json' \
        --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "suix_queryEvents",
  "params": [
    {
      "All": []
    },
    null,
    50,
    true
  ]
}' | jq .

Stack


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:
  • Nodes (Validators and Full nodes): Remove unsupported compound filters for querying events from the JSON-RPC schema to avoid confusion. Remove support for compound filters from the deprecated events subscription system.
  • Indexer: Remove compound filters for querying events.
  • JSON-RPC:
  • GraphQL:
  • CLI:
  • Rust SDK:
  • REST API:

@amnn amnn self-assigned this Sep 30, 2024
Copy link

vercel bot commented Sep 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 30, 2024 5:10pm
3 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Sep 30, 2024 5:10pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Sep 30, 2024 5:10pm
sui-typescript-docs ⬜️ Ignored (Inspect) Visit Preview Sep 30, 2024 5:10pm

@@ -1012,8 +1012,9 @@ impl IndexerReader {
.await;
} else {
let main_where_clause = match filter {
EventFilter::Package(package_id) => {
format!("package = '\\x{}'::bytea", package_id.to_hex())
EventFilter::All(fs) if fs.is_empty() => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Adding support for "All": [] to the indexer reader -- this was a rare case where IndexerReader didn't have a way to do something that the fullnode did).

impl EventFilter {
fn try_matches(&self, item: &SuiEvent) -> SuiResult<bool> {
Ok(match self {
impl Filter<SuiEvent> for EventFilter {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is removing Any, Not, Package, EventField which were not supported by either Fullnode or PG JSON-RPC, but they are part of the (deprecated) events subscription system on fullnodes. What is our policy on features like that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already well past the release where we said we'd initially remove support for subscriptions, they are effectively deprecated so we can probably choose to either remove these compound filters from the code and we can highlight that the feature is deprecated and support will continue to be pruned down till its removed, or we just leave it as is. In either case I think we should make sure that these filters are completely removed from documentation, i've found that they've been a constant source of confusion in the docs since they generally aren't supported

impl EventFilter {
fn try_matches(&self, item: &SuiEvent) -> SuiResult<bool> {
Ok(match self {
impl Filter<SuiEvent> for EventFilter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are already well past the release where we said we'd initially remove support for subscriptions, they are effectively deprecated so we can probably choose to either remove these compound filters from the code and we can highlight that the feature is deprecated and support will continue to be pruned down till its removed, or we just leave it as is. In either case I think we should make sure that these filters are completely removed from documentation, i've found that they've been a constant source of confusion in the docs since they generally aren't supported

@@ -203,15 +203,16 @@ fn try_into_byte(v: &Value) -> Option<u8> {
#[serde_as]
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
pub enum EventFilter {
/// Query by events that match all the given filters, or return all events if no filters are
/// supplied.
All(Vec<EventFilter>),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only empty vec is implemented, we can just do All here? one step further, having an All filter seems un-necessary and we can change query: EventFilter to Option<EventFilter>? Both can be more breaking so okay to me if we want to minimize the breaking here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not too happy with how All works today and the fact that this is how you communicate "no filter" (vs. how it's done for transactions which is to omit the filter), but I opted to do it this way to minimise breakage.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be clearer to have this be a fixed-size, 0-sized array? Assuming that it minimizes breakage in the same way as we have here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I initially tried to make this a unit type for similar reasons, but that made serde very unhappy. I can try [EventFilter; 0] though!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0-size array worked! 🎉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huzza for the type system!

## Description

This PR removes EventFilters from JSON-RPC that aren't supported
already by fullnode-backed JSON-RPC:

- Combination filters (`All`, `Any`, `Not`, `And`, `Or`)
- `Package`
- `EventField`

These filters were, however, supported by the now-deprecated
subscription system, so a question remains whether they are safe to
remove.

## Test plan

Manually tested, in particular `All: []` support, which we do still need
to keep as a way to get all filters (this was also added to the
`IndexerReader` implementation):

```
sui$ cargo run --bin sui -- --force-regenesis \
  --with-indexer --with-faucet
```

...run for some time, so that some system events accumulate, then test
that we get them from both the fullnode-backed JSONRPC and
indexer-backed:

Fullnode:
```
curl -LX POST  "http://localhost:9000" \
        --header 'Content-Type: application/json' \
        --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "suix_queryEvents",
  "params": [
    {
      "All": []
    },
    null,
    50,
    true
  ]
}' | jq .
```

Indexer:
```
curl -LX POST  "http://localhost:9124" \
        --header 'Content-Type: application/json' \
        --data '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "suix_queryEvents",
  "params": [
    {
      "All": []
    },
    null,
    50,
    true
  ]
}' | jq .
```
@amnn amnn force-pushed the amnn/idx-rm-complex-ev-filters branch from 3524514 to 800fe53 Compare September 30, 2024 17:09
@amnn amnn merged commit 9c6029b into main Sep 30, 2024
47 of 48 checks passed
@amnn amnn deleted the amnn/idx-rm-complex-ev-filters branch September 30, 2024 18:02
amnn added a commit that referenced this pull request Sep 30, 2024
…19618)

## Description

Broaden the definition of "affected object" to include objects that a
transaction creates and then immediately wraps, or objects that it
unwraps and then immediately deletes. This ensures that a transaction
will show up in the response to an `affectedObject` query if and only if
the Object's ID shows up in its `objectChanges` response.

## Test plan

Updated GraphQL E2E test:

```
sui$ cargo nextest run -p sui-graphql-e2e-tests \
  --features staging -- affected_object
```

## Stack

- #19474 
- #19614 
- #19615 
- #19616 
- #19617

---

## 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: 
- [ ] Nodes (Validators and Full nodes): 
- [x] Indexer: A transaction's "affected objects" include objects that
it created and wrapped, or unwrapped.
- [x] JSON-RPC: A transaction's "affected objects" include objects that
it created and wrapped, or unwrapped.
- [x] GraphQL: A transaction's "affected objects" include objects that
it created and wrapped, or unwrapped.
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
amnn added a commit that referenced this pull request Oct 10, 2024
## 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
amnn added a commit that referenced this pull request Oct 10, 2024
## 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:
amnn added a commit that referenced this pull request Oct 10, 2024
## 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:
amnn added a commit that referenced this pull request Oct 10, 2024
## 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:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants