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: allow to override provider url upon installation #346

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

gregorydemay
Copy link
Member

@gregorydemay gregorydemay commented Dec 19, 2024

Allow to override the URL that will be queried by the EVM RPC canister via a regex specified upon canister installation. This is allows testing against a local Ethereum development setup (such as foundry) without changing the client calling the EVM RPC canister.

@gregorydemay gregorydemay marked this pull request as ready for review December 20, 2024 15:11
@gregorydemay gregorydemay requested a review from a team as a code owner December 20, 2024 15:11
@@ -1,3 +1,4 @@
use crate::memory::get_override_provider;
use crate::{

Choose a reason for hiding this comment

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

nit: you could merge this import with the one below.

evm_rpc_types::LogFilter::HidePattern(regex) => LogFilter::HidePattern(regex.into()),
}
evm_rpc_types::LogFilter::ShowPattern(regex) => {
LogFilter::ShowPattern(RegexString::try_from(regex)?)

Choose a reason for hiding this comment

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

nit: I guess this is really just a taste difference, but maybe .try_into()??

match &self.override_url {
None => Ok(api),
Some(substitution) => {
let regex = substitution.pattern.compile()?;

Choose a reason for hiding this comment

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

Suggestion: Maybe I'm missing something here, but it seems we could cache the result of the pattern.compile() call by e.g. having the compiled pattern in RegexSubstitution instead of a RegexString since it's a relatively expensive operation. I guess this is currently only really relevant for local development since in prod the substitution is empty anyways, so it's not a big deal either way.

}
}

fn arb_regex() -> impl Strategy<Value = RegexString> {

Choose a reason for hiding this comment

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

Suggestion: Would it make sense to try some actual valid regexes here since, statistically speaking, the probability that this is actually a regex with a valid pattern is quite low... I would even suggest using prop_oneof! and testing both cases of a purely random string and a somewhat random but well-formed pattern.

Another risk of course is that a random string might not be a well-formed regex and might lead to test flakiness...

@lpahlavi
Copy link

Overall LGTM! Just have one or two minor comments/suggestions.

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.

2 participants