Skip to content

Conversation

@afck
Copy link
Contributor

@afck afck commented Nov 19, 2025

Motivation

It's useful to filter out spam messages on a node service that e.g. is running a chain specifically for one application.

Proposal

Allow filtering in two ways:

  • All bundles that contain at least one message for a whitelisted app.
  • All bundles that contain only messages for whitelisted apps.

The latter is stricter, but the former can be useful e.g. for apps that create other apps and then call them.

Test Plan

A test for the new filtering options was added. (Claude)

Release Plan

  • These changes should be backported to testnet_conway, then
    • be released in a new SDK.

Links

@afck afck requested review from bart-linera, deuszx and ma2bd November 19, 2025 13:18
CLI.md Outdated
Comment on lines 172 to 173
* `--accept-messages-with-application-ids <ACCEPT_MESSAGES_WITH_APPLICATION_IDS>` — A set of application IDs. If specified, only bundles with at least one message from one of these applications will be accepted
* `--reject-messages-with-other-application-ids <REJECT_MESSAGES_WITH_OTHER_APPLICATION_IDS>` — A set of application IDs. If specified, only bundles where all messages are from one of these applications will be accepted
Copy link
Contributor

Choose a reason for hiding this comment

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

and if the same application ID is in both sets? Then the REJECT_MESSAGES_WITH_OTHER_APPLICATION_IDS takes precedence?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, exactly: both filters are applied, and the stricter one wins.

/// A collection of applications: If `Some`, only bundles with at least one message by any
/// of these applications will be accepted.
accept_messages_with_application_ids: Option<HashSet<GenericApplicationId>>,
reject_messages_with_other_application_ids: Option<HashSet<GenericApplicationId>>,
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be documented as well, even if just for completeness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 4e5fc48.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about renaming accept_messages_with_application_ids into reject_message_bundles_without_application_ids ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 9d53a2d.

Copy link
Contributor

Choose a reason for hiding this comment

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

in other places we used required application IDs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What names would you suggest for the two fields then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess we could use restrict_to_application_ids and required_application_ids?

Copy link
Contributor

Choose a reason for hiding this comment

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

Funny thing is we already use exactly required_application_ids in ApplicationDescription:

    /// Required dependencies.
    pub required_application_ids: Vec<ApplicationId>,

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And we already use restrict_chain_ids_to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ma2bd: How do you feel about restrict_to_application_ids and required_application_ids?

(These are client options, so it's only clear from the help text, not from the name, that these refer to incoming message bundles. Alternatively, we could also rename restrict_chain_ids_to, to include "messages" or "message bundles".)

@afck afck enabled auto-merge November 19, 2025 15:45
@afck afck added this pull request to the merge queue Nov 19, 2025
@afck afck removed this pull request from the merge queue due to a manual request Nov 19, 2025
@afck afck enabled auto-merge November 19, 2025 16:26
@afck afck added this pull request to the merge queue Nov 19, 2025
@afck afck removed this pull request from the merge queue due to a manual request Nov 19, 2025
CLI.md Outdated

* `--restrict-chain-ids-to <RESTRICT_CHAIN_IDS_TO>` — A set of chains to restrict incoming messages from. By default, messages from all chains are accepted. To reject messages from all chains, specify an empty string
* `--reject-message-bundles-without-application-ids <REJECT_MESSAGE_BUNDLES_WITHOUT_APPLICATION_IDS>` — A set of application IDs. If specified, only bundles with at least one message from one of these applications will be accepted
* `--reject-messages-with-other-application-ids <REJECT_MESSAGES_WITH_OTHER_APPLICATION_IDS>` — A set of application IDs. If specified, only bundles where all messages are from one of these applications will be accepted
Copy link
Contributor

Choose a reason for hiding this comment

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

sorry but should it be also "message-bundles" here then?

@afck afck added this pull request to the merge queue Nov 19, 2025
@afck afck removed this pull request from the merge queue due to a manual request Nov 19, 2025
@ma2bd ma2bd added this pull request to the merge queue Nov 19, 2025
Merged via the queue into linera-io:main with commit 9a9454f Nov 19, 2025
32 checks passed
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.

Allow the client to restrict incoming messages to an application.

4 participants