-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(sew): ADR-029 generalized unbonding and babylon v0.13.0 #87
Conversation
@@ -426,7 +427,7 @@ func (sew *StakingEventWatcher) watchForSpend(spendEvent *notifier.SpendEvent, t | |||
return | |||
} | |||
|
|||
schnorrSignature, err := tryParseStakerSignatureFromSpentTx(spendingTx, td) | |||
_, err := tryParseStakerSignatureFromSpentTx(spendingTx, td) |
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 function actually checks whether stake spending transaction is unbonding transaction registered to Babylon.
So imo we can leave it but we should send inclusion proof through sew.reportUnbondingToBabylon(quitCtx, delegationId, spendingTx, proof)
even if it returns error (as now we have possibility to report even invalid unbondings to Babylon)
So the only difference between error case and non err case is metrics which we are incrementing.
return nil, err | ||
} | ||
|
||
if status != btcclient.TxInChain { |
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 wonder whether we need this check i.e whether <-spendEvent.Spend:
return when tx is in the mempool or in chain. (eitherway better to have it just in case)
func (sew *StakingEventWatcher) buildSpendingTxProof(spendingTx *wire.MsgTx) (*btcstakingtypes.InclusionProof, error) { | ||
txHash := spendingTx.TxHash() | ||
if len(spendingTx.TxOut) == 0 { | ||
return nil, fmt.Errorf("stake spending tx has no outputs") |
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.
tbh this should not happen as we are handling tx after we detected it was included in mempool/chain. Maybe panic here or have some error which we do not retry ? (imo this means our assumptions are broken so we should do something drastic)
signer := bca.babylonClient.MustGetAddr() | ||
|
||
var stakeSpendingTxBuf bytes.Buffer | ||
if err := stakeSpendingTx.Serialize(&stakeSpendingTxBuf); err != nil { |
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.
on bbn
(bbn "github.com/babylonlabs-io/babylon/types"
)we have this helper - bbn.SerializeBTCTx(
sew.logger.Errorf("unbonding tx %s for staking tx %s proof not built", spendingTxHash, delegationId) | ||
return | ||
} | ||
sew.reportUnbondingToBabylon(quitCtx, delegationId, spendingTx, proof) | ||
sew.waitForDelegationToStopBeingActive(quitCtx, delegationId) |
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.
we probably do not need it here any more, as after succesful unbonding report delegation won't be active (and reportUnbondingToBabylon
has acitvity check inside)
Extends staking event watcher to be able to send whole stake spending tx as well as inclusion proof.