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

fix: don't depend on std features from lightning-invoice #3839

Merged

Conversation

elsirion
Copy link
Contributor

@elsirion elsirion commented Dec 5, 2023

Fixes #3837. Would be awesome if you could test this today @TonyGiorgio so we can get it into 0.2.0.

@elsirion elsirion force-pushed the 2023-12-no-std-lightning-invoice branch from da3ee32 to 0eb470e Compare December 5, 2023 10:18
Copy link

codecov bot commented Dec 5, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (60daa84) 57.31% compared to head (0eb470e) 57.26%.

Files Patch % Lines
modules/fedimint-ln-common/src/lib.rs 0.00% 8 Missing ⚠️
modules/fedimint-ln-client/src/pay.rs 45.45% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3839      +/-   ##
==========================================
- Coverage   57.31%   57.26%   -0.05%     
==========================================
  Files         193      193              
  Lines       42458    42467       +9     
==========================================
- Hits        24334    24320      -14     
- Misses      18124    18147      +23     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@elsirion elsirion marked this pull request as ready for review December 5, 2023 10:33
@elsirion elsirion requested review from a team as code owners December 5, 2023 10:33
Copy link
Contributor

@justinmoon justinmoon left a comment

Choose a reason for hiding this comment

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

LGTM

@elsirion elsirion added this pull request to the merge queue Dec 5, 2023
Merged via the queue into fedimint:master with commit af69ced Dec 5, 2023
22 checks passed
@elsirion elsirion deleted the 2023-12-no-std-lightning-invoice branch December 5, 2023 13:59
@TonyGiorgio
Copy link
Contributor

No, not working. Still uses is_expired() which is also being a std flag. We'll probably just edit our fork of LDK to allow some of the std flags in wasm32 that don't explicitly use SystemTime::now().

@elsirion
Copy link
Contributor Author

elsirion commented Dec 5, 2023

Ahhh, damn it. I removed all the added calls to non-std functions, is_expired existed before, but I didn't consider that I moved it from the gateway to the client crate. So you should be able to just add that function as unimplemented! to your fork, let's figure out a way to test that we don't use std there longer term (#3838).

@TonyGiorgio
Copy link
Contributor

Thanks for your help. Added a comment there. I'll try a few things out in our patch and get it working again. Thank you!

@TonyGiorgio
Copy link
Contributor

TonyGiorgio commented Dec 5, 2023

Actually, you may want to pull out is_expired(), it calls SystemTime::now(). I can add unimplemented or false on our end but you'll run into this as well running the fedimint client in any wasm32 environment

        #[cfg(feature = "std")]
	pub fn is_expired(&self) -> bool {
		Self::is_expired_from_epoch(&self.timestamp(), self.expiry_time())
	}

	/// Returns whether the expiry time from the given epoch has passed.
	#[cfg(feature = "std")]
	pub(crate) fn is_expired_from_epoch(epoch: &SystemTime, expiry_time: Duration) -> bool {
		match epoch.elapsed() {
			Ok(elapsed) => elapsed > expiry_time,
			Err(_) => false,
		}
	}
    #[stable(feature = "time2", since = "1.8.0")]
    pub fn elapsed(&self) -> Result<Duration, SystemTimeError> {
        SystemTime::now().duration_since(*self)
    }

@elsirion
Copy link
Contributor Author

elsirion commented Dec 5, 2023

Currently this is_expired fn is only called on the gateway and not the user client. But I'll fix, just not sure if worth backporting. Thx for your help in tracking this down too!

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.

Client should not rely on std features of lightning-invoice
3 participants