Skip to content

Commit

Permalink
chore: rename BtcDelegationTxHash to BabylonBTCDelegationTxHash
Browse files Browse the repository at this point in the history
  • Loading branch information
RafilxTenfen committed Nov 28, 2024
1 parent a97cd8c commit 0a2eb54
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 50 deletions.
47 changes: 24 additions & 23 deletions proto/transaction.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion proto/transaction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ message TrackedTransaction {
bool watched = 11;
// this data is only filled if tracked transactions state is >= SENT_TO_BABYLON
UnbondingTxData unbonding_tx_data = 12;
string btcDelegationTxHash = 13;
string babylonBTCDelegationTxHash = 13;
}
8 changes: 4 additions & 4 deletions staker/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ func (event *stakingTxBtcConfirmedEvent) EventDesc() string {
}

type delegationSubmittedToBabylonEvent struct {
stakingTxHash chainhash.Hash
btcDelegationTxHash string
unbondingTx *wire.MsgTx
unbondingTime uint16
stakingTxHash chainhash.Hash
babylonBTCDelegationTxHash string
unbondingTx *wire.MsgTx
unbondingTime uint16
}

func (event *delegationSubmittedToBabylonEvent) EventID() chainhash.Hash {
Expand Down
12 changes: 6 additions & 6 deletions staker/stakerapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ func (app *App) SendPhase1Transaction(
tag []byte,
covenantPks []*secp256k1.PublicKey,
covenantQuorum uint32,
) (btcDelegationTxHash string, err error) {
) (babylonBTCDelegationTxHash string, err error) {
// check we are not shutting down
select {
case <-app.quit:
Expand Down Expand Up @@ -1272,10 +1272,10 @@ func (app *App) sendDelegationToBabylonTask(

// report success with the values we sent to Babylon
ev := &delegationSubmittedToBabylonEvent{
stakingTxHash: req.btcTxHash,
btcDelegationTxHash: delegationTxResp.TxHash,
unbondingTx: delegationData.Ud.UnbondingTransaction,
unbondingTime: delegationData.Ud.UnbondingTxUnbondingTime,
stakingTxHash: req.btcTxHash,
babylonBTCDelegationTxHash: delegationTxResp.TxHash,
unbondingTx: delegationData.Ud.UnbondingTransaction,
unbondingTime: delegationData.Ud.UnbondingTxUnbondingTime,
}

utils.PushOrQuit[*delegationSubmittedToBabylonEvent](
Expand Down Expand Up @@ -1634,7 +1634,7 @@ func (app *App) handleStakingEvents() {

case ev := <-app.delegationSubmittedToBabylonEvChan:
app.logStakingEventReceived(ev)
if err := app.txTracker.SetTxSentToBabylon(&ev.stakingTxHash, ev.btcDelegationTxHash, ev.unbondingTx, ev.unbondingTime); err != nil {
if err := app.txTracker.SetTxSentToBabylon(&ev.stakingTxHash, ev.babylonBTCDelegationTxHash, ev.unbondingTx, ev.unbondingTime); err != nil {
// TODO: handle this error somehow, it means we received confirmation for tx which we do not store
// which is seems like programming error. Maybe panic?
app.logger.Fatalf("Error setting state for tx %s: %s", ev.stakingTxHash, err)
Expand Down
26 changes: 13 additions & 13 deletions stakerdb/trackedtranactionstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ type StoredTransaction struct {
Pop *ProofOfPossession
// Returning address as string, to avoid having to know how to decode address
// which requires knowing the network we are on
StakerAddress string
State proto.TransactionState
Watched bool
UnbondingTxData *UnbondingStoreData
BtcDelegationTxHash string
StakerAddress string
State proto.TransactionState
Watched bool
UnbondingTxData *UnbondingStoreData
BabylonBTCDelegationTxHash string
}

// StakingTxConfirmedOnBtc returns true only if staking transaction was sent and confirmed on bitcoin
Expand Down Expand Up @@ -368,11 +368,11 @@ func protoTxToStoredTransaction(ttx *proto.TrackedTransaction) (*StoredTransacti
BtcSigType: ttx.BtcSigType,
BtcSigOverBabylonAddr: ttx.BtcSigOverBbnStakerAddr,
},
StakerAddress: ttx.StakerAddress,
State: ttx.State,
Watched: ttx.Watched,
UnbondingTxData: utd,
BtcDelegationTxHash: ttx.BtcDelegationTxHash,
StakerAddress: ttx.StakerAddress,
State: ttx.State,
Watched: ttx.Watched,
UnbondingTxData: utd,
BabylonBTCDelegationTxHash: ttx.BabylonBTCDelegationTxHash,
}, nil
}

Expand Down Expand Up @@ -721,7 +721,7 @@ func (c *TrackedTransactionStore) AddTransactionSentToBabylon(
State: proto.TransactionState_SENT_TO_BABYLON,
Watched: false,
UnbondingTxData: update,
BtcDelegationTxHash: btcDelTxHash,
BabylonBTCDelegationTxHash: btcDelTxHash,
}

inputData, err := getInputData(btcTx)
Expand Down Expand Up @@ -978,7 +978,7 @@ func (c *TrackedTransactionStore) SetTxConfirmed(

func (c *TrackedTransactionStore) SetTxSentToBabylon(
txHash *chainhash.Hash,
btcDelegationTxHash string,
babylonBTCDelegationTxHash string,
unbondingTx *wire.MsgTx,
unbondingTime uint16,
) error {
Expand All @@ -994,7 +994,7 @@ func (c *TrackedTransactionStore) SetTxSentToBabylon(

tx.State = proto.TransactionState_SENT_TO_BABYLON
tx.UnbondingTxData = update
tx.BtcDelegationTxHash = btcDelegationTxHash
tx.BabylonBTCDelegationTxHash = babylonBTCDelegationTxHash
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions stakerservice/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ func (s *StakerService) btcDelegationFromBtcStakingTx(
return nil, err
}

btcDelegationTxHash, err := s.staker.SendPhase1Transaction(stakerAddr, stkTxHash, tag, covenantPks, covenantQuorum)
babylonBTCDelegationTxHash, err := s.staker.SendPhase1Transaction(stakerAddr, stkTxHash, tag, covenantPks, covenantQuorum)
if err != nil {
s.logger.WithError(err).Info("err to send phase 1 tx")
return nil, err
}

return &ResultBtcDelegationFromBtcStakingTx{
TxHashDelegationBTC: btcDelegationTxHash,
BabylonBTCDelegationTxHash: babylonBTCDelegationTxHash,
}, nil
}

Expand Down
2 changes: 1 addition & 1 deletion stakerservice/stakerdresponses.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "github.com/btcsuite/btcd/btcjson"
type ResultHealth struct{}

type ResultBtcDelegationFromBtcStakingTx struct {
TxHashDelegationBTC string `json:"tx_hash_delegation_btc"`
BabylonBTCDelegationTxHash string `json:"babylon_btc_delegation_tx_hash"`
}

type ResultStake struct {
Expand Down

0 comments on commit 0a2eb54

Please sign in to comment.