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

Restore operation log entries for deposits #5915

Merged
merged 2 commits into from
Aug 26, 2024

Conversation

elsirion
Copy link
Contributor

@elsirion elsirion commented Aug 24, 2024

The functionality to list and observe deposits was accidentally removed in #5473.

It's a bit tricky because technically a single generated address can now cause multiple operations. My plan is to create a first operation on address generation, this will correspond to the first deposit seen on-chain.

Possible extension

Any successive deposit could result in another operation log entry. Since this will be hard to do 100% consistently (we don't model the "transaction seen but unconfirmed" state anymore) and the previous behavior was to ignore this anyway I'm not including this here.

@elsirion elsirion force-pushed the 2024-08-restore-deposit-log branch from 48b3286 to 2002349 Compare August 25, 2024 10:32
@elsirion elsirion requested review from dpc and maan2003 August 25, 2024 10:35
@elsirion elsirion changed the title WIP: Restore operation log entries for deposits Restore operation log entries for deposits Aug 25, 2024
@elsirion elsirion force-pushed the 2024-08-restore-deposit-log branch from 2002349 to 1470dbc Compare August 25, 2024 12:06
@elsirion elsirion marked this pull request as ready for review August 25, 2024 12:31
@elsirion elsirion requested review from a team as code owners August 25, 2024 12:31
Comment on lines 674 to 684
/// Returns an error for old deposit operations created prior to the 0.4
/// release and not driven to completion yet. This should be rare enough
/// that an indeterminate state is ok here.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@maan2003 important to note for integrators

modules/fedimint-wallet-client/src/lib.rs Outdated Show resolved Hide resolved
Comment on lines 96 to 109
WaitingForConfirmation {
// Caution: previously this variant contained `BitcoinTransactionData`, it should not have
// been persisted by the fedimint client though
btc_out_point: bitcoin::OutPoint,
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe add confirmations?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Out of scope for this PR imo

@elsirion elsirion force-pushed the 2024-08-restore-deposit-log branch from 1470dbc to d2147eb Compare August 26, 2024 13:28
bail!("Operation is not a deposit operation");
};

let Some(tweak_idx) = tweak_idx else {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Document tweak idx being related to new oeprations

@elsirion elsirion force-pushed the 2024-08-restore-deposit-log branch from d2147eb to 136cb8b Compare August 26, 2024 15:49
Copy link
Member

@maan2003 maan2003 left a comment

Choose a reason for hiding this comment

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

me and @elsirion did two review passes synchronously

@elsirion elsirion enabled auto-merge August 26, 2024 15:53
@elsirion elsirion added this pull request to the merge queue Aug 26, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 26, 2024
@maan2003 maan2003 added this pull request to the merge queue Aug 26, 2024
Merged via the queue into fedimint:master with commit 5e42475 Aug 26, 2024
23 checks passed
@fedimint-backports
Copy link

Backport failed for releases/v0.4, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin releases/v0.4
git worktree add -d .worktree/backport-5915-to-releases/v0.4 origin/releases/v0.4
cd .worktree/backport-5915-to-releases/v0.4
git switch --create backport-5915-to-releases/v0.4
git cherry-pick -x ceeec00b4c5a821791c39508ce31832261544ebe 136cb8b7665d43d3b686280cbca8c5f3e101afd1

Copy link
Contributor

@dpc dpc 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 deleted the 2024-08-restore-deposit-log branch August 26, 2024 20:09
},
Claimed {
#[serde(with = "bitcoin::amount::serde::as_sat")]
btc_deposited: bitcoin::Amount,
Copy link
Contributor

Choose a reason for hiding this comment

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

@maan2003 and I were looking at this and I learned that this amount does not take into account the fee that we deducted by the federation.. maybe this is OK for now since the fee is a fixed amount.. but probably not the best pattern. I imagine an integrator would want to know the amount of BTC that was actually "claimed" to be used as their e-cash.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, unfortunately it's very hard to accurately show the amount received once e-cash fees are taken into account. So rather than showing a mostly correct value I opted for just supplying the raw deposit value.

This PR is in no way ideal, it's a stop-gap solution till we probably rebuild the pegin monitor to allow for better observeability.

btc_out_point,
}).await;

yield DepositStateV2::Claimed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering if we're missing the "await_primary_module_output" (or equivalent) here to actually indicate in the update stream that the e-cash has been issued and added to the balance..? Similar to https://github.com/fedimint/fedimint/blob/5e4247572386518809f5edb86397451a523edf3e/modules/fedimint-ln-client/src/lib.rs#L1624C43-L1624C71

Copy link
Contributor Author

@elsirion elsirion Aug 27, 2024

Choose a reason for hiding this comment

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

Yeah, missed that, but should be easy to fix. Less of a prio for users imo since this shouldn't fail, but definitely useful for testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants