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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: unknown module #4399

Merged
merged 5 commits into from
Feb 27, 2024
Merged

feat: unknown module #4399

merged 5 commits into from
Feb 27, 2024

Conversation

dpc
Copy link
Contributor

@dpc dpc commented Feb 22, 2024

We would like to make sure all client code can gracefully handle Federations with modules that the client doesn't support.

The laziest way to do it is to add a new dummy module that has only server side implementation and then instantiate it liberally in tests. This should exercise code paths handling such case without any 馃 downsides.

Easy to test with just mprocs:

image

@dpc dpc requested review from a team as code owners February 22, 2024 18:57
Comment on lines 192 to 196
if std::env::var_os(FM_USE_UNKNOWN_MODULE_ENV).is_some() {
s.with_module(UnknownInit)
} else {
s
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of branching like this in production code just to make tests work. Aren't rust integration tests enough? If we really want devimint tests we can build a separate testing fedimintd with this extra module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Having separate binaries seem cumbersome for integrations and alike. There's really nothing hacky or insecure about this module, it's a proper module that... is not very useful in practice. If you don't like branching, I could just make fedimintd produce this module unconditionally. :D

I bet eventually default Fedimint will ship with some optional modules anyway, or even the current modules will become opitonal, and users will be choosing them at DKG. It's just we don't have this API surface yet, so an env var is used.

@dpc dpc requested a review from a team as a code owner February 22, 2024 22:16
@@ -11,6 +11,9 @@ versions=( "${@:-${default_versions[@]}}" )

# signal to downstream test scripts
export FM_BACKWARDS_COMPATIBILITY_TEST=1
# previous versions did not have unknown module so can't support it,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bradleystachurski Food for thought: we will need to deal with all sorts of incompatibilities between versions.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I'd anticipate we'll have a lot of conditional logic in devimint based on versions similar to 18f00a8 (#4247)

Copy link
Member

Choose a reason for hiding this comment

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

It might be useful to come up with a system that'll allow us to easily cleanup conditional logic that's no longer needed in devimint.

e.g. // FIXME: deprecated v0.2.1 so we can grep for a version when it's reached EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

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

馃 But we should make it an issue and brainstorm a little.

Copy link
Member

Choose a reason for hiding this comment

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

馃憤 #4424

@dpc
Copy link
Contributor Author

dpc commented Feb 22, 2024

Hey, it detected one legitimate bug right away.

@justinmoon
Copy link
Contributor

#3548 will be a good one to test with this

@dpc
Copy link
Contributor Author

dpc commented Feb 23, 2024

#3548 will be a good one to test with this

That was the one it found, I just pushed it as a separate PR, as it's not clear when we'll land this and how yet.

elsirion
elsirion previously approved these changes Feb 23, 2024
.clone()
.decoded()
.map(|decoded| decoded.to_json().into())
.unwrap_or(serde_json::Value::Null),
Copy link
Contributor

Choose a reason for hiding this comment

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

Eventually we might want to display the raw binary instead of null?

elsirion
elsirion previously approved these changes Feb 26, 2024
Copy link
Member

@bradleystachurski bradleystachurski left a comment

Choose a reason for hiding this comment

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

Looks good!

CI is complaining but I think you can resolve by building locally and committing Cargo.lock.

@@ -140,6 +140,7 @@ pub const MODULE_INSTANCE_ID_GLOBAL: u16 = u16::MAX;
pub const LEGACY_HARDCODED_INSTANCE_ID_LN: ModuleInstanceId = 0;
pub const LEGACY_HARDCODED_INSTANCE_ID_MINT: ModuleInstanceId = 1;
pub const LEGACY_HARDCODED_INSTANCE_ID_WALLET: ModuleInstanceId = 2;
pub const LEGACY_HARDCODED_INSTANCE_ID_UNKNOWN: ModuleInstanceId = 3;
Copy link
Member

Choose a reason for hiding this comment

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

Is the comment above still relevant?

// Note: needs to be in alphabetical order of ModuleKind of each module,
// as this is the ordering we currently hardcoded.

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 just got rid of it.

fedimint-core/src/encoding/mod.rs Show resolved Hide resolved
fedimint-core/src/envs.rs Show resolved Hide resolved
@@ -113,6 +113,19 @@ impl Fixtures {
self
}

pub fn with_server_only_module(
Copy link
Member

Choose a reason for hiding this comment

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

Would this make sense to use for other fixtures instead of only ln-gateway?

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, but with very diminishing returns.

modules/fedimint-unknown-server/Cargo.toml Outdated Show resolved Hide resolved
modules/fedimint-unknown-server/src/lib.rs Outdated Show resolved Hide resolved
@dpc dpc added this pull request to the merge queue Feb 27, 2024
Merged via the queue into fedimint:master with commit d5b886e Feb 27, 2024
20 checks passed
@dpc dpc deleted the 24-02-22-unknown-module branch February 27, 2024 10:50
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.

None yet

4 participants