-
Notifications
You must be signed in to change notification settings - Fork 2
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: new command phase1 stake to BTC delegation #90
base: main
Are you sure you want to change the base?
Conversation
…lx/migrate-stk-to-phase2
…-io/btc-staker into rafilx/migrate-stk-to-phase2
…lx/migrate-stk-to-phase2
…lx/migrate-stk-to-phase2
@@ -1,6 +1,6 @@ | |||
// Code generated by protoc-gen-go. DO NOT EDIT. | |||
// versions: | |||
// protoc-gen-go v1.33.0 | |||
// protoc-gen-go v1.35.1 |
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.
not sure why this updated, just run proto-gen
staker/stakerapp.go
Outdated
// eventually tx is send to babylon | ||
storedTx, err := app.waitForTrackedTransactionState(stkTxHash, proto.TransactionState_SENT_TO_BABYLON, time.Second, 20) | ||
if err != nil { | ||
utils.PushOrQuit( | ||
cmd.errChan, | ||
err, | ||
app.quit, | ||
) | ||
app.logger.WithFields(logrus.Fields{ | ||
"stakingTxHash": stkTxHash, | ||
}).Debugf("BTC delegation waited for too long to become active, check the status manually") | ||
continue | ||
} |
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.
not fully convinced it is a good idea to retrieve the consumer delegation tx hash this way
One last thing is that I noticed some flankiness in the integration test
The failed one indicates that some datagen function from babylon to insert the covenant sig is not behaving as expected 2024-11-26T02:20:08.9985192Z manager.go:1159:
2024-11-26T02:20:08.9986075Z Error Trace: /home/runner/work/btc-staker/btc-staker/itest/manager.go:1159
2024-11-26T02:20:08.9987678Z /home/runner/work/btc-staker/btc-staker/itest/e2e_test.go:977
2024-11-26T02:20:08.9988437Z Error: Received unexpected error:
2024-11-26T02:20:08.9990075Z invalid tx: txToSign inpunt index must point to output with provided script
2024-11-26T02:20:08.9990856Z Test: TestStakeFromPhase1
2024-11-26T02:20:08.9991493Z time="2024-11-26T02:17:42Z" level=info msg="Received shutdown signal. Stopping..." The check that fails if txToSign.TxIn[0].PreviousOutPoint.Index != fundingOutputIdx {
return fmt.Errorf("txToSign inpunt index must point to output with provided script")
}
|
staker/stakerapp.go
Outdated
} | ||
|
||
bestBlockHeight := app.currentBestBlockHeight.Load() | ||
if err := app.waitForStakingTransactionConfirmation( |
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 in this handler I would
- return error if transaction is not confirmed on BTC already (less state to hold on to)
- do the same thing that function
handlePreApprovalCmd
does but with inclusion proof . Maybe you can even reuse this function somehow. Then this new staking info will be saved in db only after send to Babylon succeeds.
This way we will avoid this waiting go rutine:
go func() {
// eventually tx is send to babylon and notifies the cmd request
storedTx, err := app.waitForTrackedTransactionState(stkTxHash, proto.TransactionState_SENT_TO_BABYLON, time.Second, 20)
and we won't need to store delegation transaction txhash in db as it could be returned immediately from handlePreApprovalCmd
function
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.
You are correct, it became much simpler! Thanks
One thing is that I would still keep the BTC delegation tx hash in the TrackedTransaction I believe it helps to track the transaction in the other side
Let me know if you want to be removed
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.
One thing is that I would still keep the BTC delegation tx hash in the TrackedTransaction I believe it helps to track the transaction in the other side
hmm makes sense. Lets leave it then 👍
Ahh I see, one of the test functions assumess that staking output index is zero:
but in test you create staking tx by:
and Simple fix is to set |
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.
Looks good 👍 thanks for tackling it !
Only few cleanup comments
Required: true, | ||
}, | ||
cli.Uint64Flag{ | ||
Name: txInclusionHeightFlag, |
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 wodner whether this param is necessary i.e we have staking tx hash, we can retrieve staking transaction from the btc chain and check its height and based on that chose the param.
Non-blocking comment it can be tackled as future improvement imo.
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.
good point
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 had modified to get the Block Height from the tx hash in the CLI command, but that also added one more call to service, it was done this way to avoid sending the whole global params to the service app
stakercli daemon stake-from-phase1