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

[Maker] Register Fidelity at Mempool #386

Open
mojoX911 opened this issue Jan 24, 2025 · 7 comments · May be fixed by #390
Open

[Maker] Register Fidelity at Mempool #386

mojoX911 opened this issue Jan 24, 2025 · 7 comments · May be fixed by #390
Assignees
Labels
enhancement This enhances the code and improves stuffs
Milestone

Comments

@mojoX911
Copy link

Currently, we are registering fidelity bond only when they are confirmed. This creates an edge case when the fidelity tx is in mempool and maker unexpectedly shutdown, it will loose the fund.

@mojoX911 mojoX911 added the enhancement This enhances the code and improves stuffs label Jan 24, 2025
@mojoX911 mojoX911 added this to the v0.1.1 milestone Jan 24, 2025
@KnowWhoami
Copy link
Collaborator

Well in order to register the fidelity bond before waiting for its confirmation -> we have to create a fidelity bond instance before looping for fidelitiy tx confirmation which requires confirmation height of this tx which can't be known before this tx got confirmed.

Also we would also need to calculate certificate expiry of the bond which is based on current block height.
and calculating this expiry value before the waiting for the confirmation may lead to misleading expiry values.

let cert_expiry = self.get_fidelity_expiry()?;
let bond = FidelityBond {
outpoint: OutPoint::new(txid, 0),
amount,
lock_time: locktime,
pubkey: fidelity_pubkey,
conf_height,
cert_expiry,
};
let bond_spk = bond.script_pub_key();
self.store
.fidelity_bond
.insert(index, (bond, bond_spk, false));

@KnowWhoami
Copy link
Collaborator

One way could be just assume its confirmation height = current height +1.
and calculated the expiry values based on that?

@mojoX911
Copy link
Author

Just change it to Option<height>?

@mojoX911
Copy link
Author

Also we would also need to calculate certificate expiry of the bond which is based on current block height.
and calculating this expiry value before the waiting for the confirmation may lead to misleading expiry values.

Same has height. Change it to option. When in mempool these values will be None. For a valid fidelity they should always be Some.

@KnowWhoami
Copy link
Collaborator

KnowWhoami commented Jan 24, 2025

Yes, I thought about but that could create another set of problems :
Let's say we created a bond instance with the conf_height as None and register this bond in the maker wallet.
Now if maker server unexpectedly shutdown while waiting for the confirmation. Then we wouldn't be able to edit the confirmation height of the bond. Thus this bond would now have None confirmation height and certificate expiry.

@mojoX911
Copy link
Author

Yes in that case the next time the maker starts up, it should be able to identify the bond with None, wait for its confirmation then change the values.

The only thing it can do after getting a None is wait for confirmation, and don't proceed further until it's confirmed.

Even if it shuts down with the None value, it shouldn't be a problem.

@KnowWhoami
Copy link
Collaborator

yeah, makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This enhances the code and improves stuffs
Projects
Status: WIP
Development

Successfully merging a pull request may close this issue.

2 participants