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

Enable filtering by default and remove mode.packets.filter config option #1819

Merged
merged 4 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove `mode.packets.filter` config option and enable filtering by default
([#1817](https://github.com/informalsystems/ibc-rs/issues/1817))
3 changes: 1 addition & 2 deletions ci/simple_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[telemetry]
Expand Down Expand Up @@ -58,4 +57,4 @@ max_tx_size = 2097152
gas_price = { price = 0.001, denom = 'stake' }
clock_drift = '5s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
trust_threshold = { numerator = '1', denominator = '3' }
18 changes: 3 additions & 15 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ clear_interval = 100
# Whether or not to clear packets on start. [Default: false]
clear_on_start = true

# Enable or disable the filtering mechanism.
# Valid options are 'true', 'false'.
# Currently Hermes supports two filters:
# 1. Packet filtering on a per-chain basis; see the chain-specific
# filter specification below in [chains.packet_filter].
# 2. Filter for all activities based on client state trust threshold; this filter
# is parametrized with (numerator = 1, denominator = 3), so that clients with
# thresholds different than this will be ignored.
# If set to 'true', both of the above filters will be enabled.
# [Default: false]
filter = false

# Toggle the transaction confirmation mechanism.
# The tx confirmation mechanism periodically queries the `/tx_search` RPC
# endpoint to check that previously-submitted transactions
Expand Down Expand Up @@ -207,9 +195,9 @@ trust_threshold = { numerator = '1', denominator = '3' }
memo_prefix = ''

# This section specifies the filters for policy based relaying.
# Default: no policy/ filters
# The section is ignored if the global 'filter' option is set to 'false'.
# If the global 'filter' option is set to 'true' and this section is missing then no filtering is performed for this chain.
#
# Default: no policy / filters, allow all packets on all channels.
#
# Only packet filtering based on channel identifier can be specified.
# A channel filter has two fields:
# 1. `policy` - one of two types are supported:
Expand Down
1 change: 0 additions & 1 deletion docs/architecture/adr-002-ibc-relayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[[chains]]
Expand Down
1 change: 0 additions & 1 deletion guide/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[rest]
Expand Down
11 changes: 5 additions & 6 deletions guide/src/tutorials/local-chains/relay-paths/multiple-paths.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,24 @@ Follow the steps below to connect three chains together and relay packets betwee
```toml
[global]
log_level = 'info'

[mode]

[mode.clients]
enabled = true
refresh = true
misbehaviour = true

[mode.connections]
enabled = false

[mode.channels]
enabled = false

[mode.packets]
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[[chains]]
Expand Down
1 change: 0 additions & 1 deletion relayer-cli/tests/fixtures/two_chains.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[[chains]]
Expand Down
14 changes: 1 addition & 13 deletions relayer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ pub mod default {
true
}

pub fn filter() -> bool {
false
}

pub fn clear_packets_interval() -> u64 {
100
}
Expand Down Expand Up @@ -172,13 +168,9 @@ impl Config {
port_id: &PortId,
channel_id: &ChannelId,
) -> bool {
if !self.mode.packets.filter {
return true;
}

match self.find_chain(chain_id) {
None => false,
Some(chain_config) => chain_config.packet_filter.is_allowed(port_id, channel_id),
None => false,
}
}

Expand Down Expand Up @@ -219,7 +211,6 @@ impl Default for ModeConfig {
enabled: true,
clear_interval: default::clear_packets_interval(),
clear_on_start: true,
filter: false,
tx_confirmation: true,
},
}
Expand Down Expand Up @@ -256,8 +247,6 @@ pub struct Packets {
pub clear_interval: u64,
#[serde(default)]
pub clear_on_start: bool,
#[serde(default = "default::filter")]
pub filter: bool,
#[serde(default = "default::tx_confirmation")]
pub tx_confirmation: bool,
}
Expand All @@ -268,7 +257,6 @@ impl Default for Packets {
enabled: false,
clear_interval: default::clear_packets_interval(),
clear_on_start: false,
filter: default::filter(),
tx_confirmation: default::tx_confirmation(),
}
}
Expand Down
11 changes: 6 additions & 5 deletions relayer/src/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,17 @@ pub fn spawn_rest_worker<Chain: ChainHandle>(
/// Returns `true` if the relayer should filter based on
/// client state attributes, e.g., trust threshold.
/// Returns `false` otherwise.
fn client_filter_enabled(config: &Config) -> bool {
// Currently just a wrapper over the global filter.
config.mode.packets.filter
fn client_filter_enabled(_config: &Config) -> bool {
// we currently always enable the client filter
true
}

/// Returns `true` if the relayer should filter based on
/// channel identifiers.
/// Returns `false` otherwise.
fn channel_filter_enabled(config: &Config) -> bool {
config.mode.packets.filter
fn channel_filter_enabled(_config: &Config) -> bool {
// we currently always enable the channel filter
true
}

fn relay_packets_on_channel(
Expand Down
3 changes: 2 additions & 1 deletion relayer/src/supervisor/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,8 @@ impl<'a, Chain: ChainHandle> ChainScanner<'a, Chain> {
}

fn filtering_enabled(&self) -> bool {
self.config.mode.packets.filter
// filtering is always enabled
true
}

fn use_allow_list<'b>(&self, chain_config: &'b ChainConfig) -> Option<&'b ChannelsSpec> {
Expand Down
1 change: 0 additions & 1 deletion relayer/tests/config/fixtures/relayer_conf_example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ enabled = false
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[[chains]]
Expand Down
1 change: 0 additions & 1 deletion scripts/gm/bin/lib-gm
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,6 @@ enabled = true
enabled = true
clear_interval = 100
clear_on_start = true
filter = false
tx_confirmation = true

[telemetry]
Expand Down
1 change: 0 additions & 1 deletion tools/integration-test/src/tests/client_expiration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ impl TestOverrides for ExpirationTestOverrides {
enabled: true,
clear_interval: 10,
clear_on_start: true,
filter: false,
tx_confirmation: true,
},
};
Expand Down
1 change: 0 additions & 1 deletion tools/integration-test/src/tests/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ impl TestOverrides for SupervisorTest {
enabled: true,
clear_interval: 10,
clear_on_start: true,
filter: false,
tx_confirmation: true,
},
};
Expand Down