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

feat: Adds filtering of erc20 tokens by their l2 address #447

Merged
merged 4 commits into from
Apr 24, 2024
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ Deployment is done by deploying a dockerized image of the service.
| `CUSTOM_TOKEN_ADDRESSES` | (Optional) Adds a predefined list of tokens to finalize. May be useful in case of custom bridge setups when the regular technique of finding token deployments does not work. |
| `ENABLE_WITHDRAWAL_METERING` | (Optional, default: `"true"`) By default Finalizer collects metrics about withdrawn token volumens. Users may optionally switch off this metering. |
| `ETH_FINALIZATION_THRESHOLD`| (Optional, default: "0") Finalizer will only finalize ETH withdrawals that are greater or equal to this value |
| `ONLY_FINALIZE_THESE_TOKENS` | (Optional, default: `None`) If specified, creates a whitelist of erc20 tokens that will be finalized.

The configuration structure describing the service config can be found in [`config.rs`](https://github.com/matter-labs/zksync-withdrawal-finalizer/blob/main/bin/withdrawal-finalizer/src/config.rs)

Expand Down
4 changes: 4 additions & 0 deletions bin/withdrawal-finalizer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ pub struct Config {

#[envconfig(from = "ONLY_L1_RECIPIENTS")]
pub only_l1_recipients: Option<AddrList>,

/// Only finalize these tokens specified by their L2 addresses
#[envconfig(from = "ONLY_FINALIZE_THESE_TOKENS")]
pub only_finalize_these_tokens: Option<AddrList>,
}

#[derive(Deserialize, Serialize, Debug, Eq, PartialEq)]
Expand Down
7 changes: 6 additions & 1 deletion bin/withdrawal-finalizer/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ async fn main() -> Result<()> {
tokens.extend_from_slice(custom_tokens.0.as_slice());
}

tracing::info!("tokens {tokens:?}");
if let Some(ref custom_tokens) = config.custom_token_deployer_addresses {
tokens.extend_from_slice(custom_tokens.0.as_slice());
}

if let Some(only_finalize_these_tokens) = config.only_finalize_these_tokens {
tokens.retain(|token| only_finalize_these_tokens.0.contains(token));
}

tracing::info!("tokens {tokens:?}");

let l2_events = L2EventsListener::new(
config.api_web3_json_rpc_ws_url.as_str(),
config
Expand Down
Loading