-
Notifications
You must be signed in to change notification settings - Fork 76
Make max fee rate sticky per payjoin-cli session #934
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
Conversation
192744b to
b842442
Compare
Pull Request Test Coverage Report for Build 17264256919Details
💛 - Coveralls |
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on! There is couple things here that don't seem quite right to me. I've provided some concrete suggestions to get this work on the right path.
a5f877c to
b46be2c
Compare
|
@Johnosezele Do you mind updating the ffi integration and unit tests? looks like you are just missing the new max-fee-rate param in those tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely on the right track! Had a couple questions and misc. code clean up comments.
21743b8 to
d19bbf2
Compare
Thanks, I have done this, the CI failure still persists looks like a test timeout issue Edit: |
d19bbf2 to
4f7ef10
Compare
|
The bindings should be generated on CI and this looks like a different error than before. I would try building the bindings locally and running the tests. I can also help debug later on today/tomorrow |
a13a378 to
efac7d1
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed what I think is a regression in the python integration test. And I had a question about using min() vs a overwrite of previous fee prefrences. I plan to pull this down an run some manual tests.
One more thing @Johnosezele Do you mind squashing your commits into one. And adding a description for your commit. FWIW I think your PR description does a great job describing the problem and how you solved it -- although its a bit outdated. Do you mind adding something similar to the commit message. Thank you
efac7d1 to
8ab45fa
Compare
c4cbad1 to
fc714f1
Compare
|
I see these weird conflicts with my branch and master, sadly I'm 'already up to date' with master on my local, so I'm not able to resolve these conflicts locally. When I resolve on GitHub I have some CI issues. @arminsabouri pls how do I proceed? |
fc714f1 to
ded4391
Compare
ded4391 to
9376e55
Compare
Hmm thats odd. I pull master and rebased your branch. Can't say I had the same issue. |
719eca5 to
ab1424a
Compare
|
@Johnosezele Last push cleans up the tests a bit further. |
|
Something odd I noticed. This certainly is outside the scope of this PR but wanted to note it #[test]
fn test_apply_fee_range_overrides_max() {
let original_max = FeeRate::from_sat_per_vb_unchecked(1000);
let context = SessionContext { max_fee_rate: original_max, ..SHARED_CONTEXT.clone() };
let receiver = Receiver { state: create_wants_fee_range_with_context(context) };
let new_max = Some(FeeRate::from_sat_per_vb_unchecked(2));
let result = receiver
.apply_fee_range(None, new_max)
.save(&NoopSessionPersister::default())
.expect("Noop persister shouldn't fail");
let payjoin_psbt = &result.state.psbt_context.payjoin_psbt;
let payjoin_fee = payjoin_psbt.fee().expect("PSBT should have fee");
let new_max = new_max.expect("is some");
let actual_fee_rate = payjoin_fee
/ payjoin_psbt
.clone()
.extract_tx_unchecked_fee_rate()
.weight();
println!("actual_fee_rate: {}", actual_fee_rate);
assert!(
actual_fee_rate <= original_max,
"Fee rate {actual_fee_rate} should not exceed session maximum {original_max}"
);
assert!(
actual_fee_rate <= new_max,
"Fee rate {actual_fee_rate} should not exceed session maximum {new_max}"
);
assert_eq!(result.session_context.max_fee_rate, original_max);
}Fails bc it creates a tx with a FeeRate of 502 sat/kwu . It should be less than or equal to 500. When I set the new max fee rate to a large value (eg. 42) it passes. I will test but this should fail in master as well. |
ab1424a to
afb16d3
Compare
|
|
6c918f3 to
69eb26c
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK 69eb26c
|
Paging @nothingmuch as you requested changes |
nothingmuch
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
minor nit: payjoin-cli/src/app/{main.rs,cli.mod} have some noop changes, namely Commmand::Resume is now an empty struct variant instead just an enum variant with no contents but i don't think it's worth reverting this if we expect a followup PR that intergrates this change into the CLI interface and would modify those lines anyway
since CLI stuff was postponed to later PR my suggestions my suggestions are no longer relevant for this PR |
69eb26c to
a4dfabd
Compare
|
I can see that lint failure of |
a4dfabd to
e04b363
Compare
|
Mostly lint fixes that I have just pushed compare |
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spotted regressions in ffi. Additionally please update your cargo nightly toolchain. I see some unnecessary clippy fixes.
51bfa72 to
a40cfcf
Compare
payjoin-ffi/src/receive/mod.rs
Outdated
| .map_err(|e| { | ||
| ImplementationError::from(format!( | ||
| "Session creation failed for directory {}: {}", | ||
| directory, e | ||
| )) | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| .map_err(|e| { | |
| ImplementationError::from(format!( | |
| "Session creation failed for directory {}: {}", | |
| directory, e | |
| )) | |
| }) | |
| .map_err(IntoUrlError::from) |
Make max_fee_rate persistent across payjoin session resumptions and simplify FFI layer architecture by eliminating duplicate fee rate capping logic.
- Add max_fee_rate field to SessionContext with serde defaults for
backward compatibility
- Remove session_max_fee_rate() accessor method (no longer needed)
- Simplify FFI layer to convert Option<u64> to Option<FeeRate> and
pass directly to core apply_fee_range() method
- Eliminate code duplication between FFI and core layers
- Maintain all fee rate capping logic in core library only
Fixes payjoin#897
a40cfcf to
e8680de
Compare
arminsabouri
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cACK. There are still some cosmetic changes but I'd like to move this PR along. And I'd like to merge #998 first.
|
Superseded by #1033 |
When a payjoin-cli receive session is created, the
max_fee_rateis now persisted with the session and reused when the session is resumed, instead of defaulting to the global configuration value.Core Library (
payjoin/src/core/receive/v2/mod.rs)max_fee_rateas non-optional field toSessionContextsession_max_fee_rate()accessor method (no longer needed after FFI simplification)apply_fee_range()methodFFI Layer (
payjoin-ffi/src/receive/mod.rs)Option<u64>parameters toOption<FeeRate>and pass directly to coreCLI Changes
--max-fee-rateflag when resuming sessionsBackward Compatibility
FeeRate::BROADCAST_MINas default.Resolves: #897