From 0a2eb546e889ee9955c5b2a9a69bd971bcde3417 Mon Sep 17 00:00:00 2001 From: RafilxTenfen Date: Thu, 28 Nov 2024 09:28:37 -0300 Subject: [PATCH] chore: rename BtcDelegationTxHash to BabylonBTCDelegationTxHash --- proto/transaction.pb.go | 47 +++++++++++++++--------------- proto/transaction.proto | 2 +- staker/events.go | 8 ++--- staker/stakerapp.go | 12 ++++---- stakerdb/trackedtranactionstore.go | 26 ++++++++--------- stakerservice/service.go | 4 +-- stakerservice/stakerdresponses.go | 2 +- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/proto/transaction.pb.go b/proto/transaction.pb.go index e8836bc..5323319 100644 --- a/proto/transaction.pb.go +++ b/proto/transaction.pb.go @@ -385,8 +385,8 @@ type TrackedTransaction struct { State TransactionState `protobuf:"varint,10,opt,name=state,proto3,enum=proto.TransactionState" json:"state,omitempty"` Watched bool `protobuf:"varint,11,opt,name=watched,proto3" json:"watched,omitempty"` // this data is only filled if tracked transactions state is >= SENT_TO_BABYLON - UnbondingTxData *UnbondingTxData `protobuf:"bytes,12,opt,name=unbonding_tx_data,json=unbondingTxData,proto3" json:"unbonding_tx_data,omitempty"` - BtcDelegationTxHash string `protobuf:"bytes,13,opt,name=btcDelegationTxHash,proto3" json:"btcDelegationTxHash,omitempty"` + UnbondingTxData *UnbondingTxData `protobuf:"bytes,12,opt,name=unbonding_tx_data,json=unbondingTxData,proto3" json:"unbonding_tx_data,omitempty"` + BabylonBTCDelegationTxHash string `protobuf:"bytes,13,opt,name=babylonBTCDelegationTxHash,proto3" json:"babylonBTCDelegationTxHash,omitempty"` } func (x *TrackedTransaction) Reset() { @@ -503,9 +503,9 @@ func (x *TrackedTransaction) GetUnbondingTxData() *UnbondingTxData { return nil } -func (x *TrackedTransaction) GetBtcDelegationTxHash() string { +func (x *TrackedTransaction) GetBabylonBTCDelegationTxHash() string { if x != nil { - return x.BtcDelegationTxHash + return x.BabylonBTCDelegationTxHash } return "" } @@ -572,7 +572,7 @@ var file_transaction_proto_rawDesc = []byte{ 0x42, 0x54, 0x43, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x1e, 0x75, 0x6e, 0x62, 0x6f, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x54, 0x78, 0x42, 0x74, 0x63, 0x43, 0x6f, 0x6e, 0x66, 0x69, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, - 0x6e, 0x66, 0x6f, 0x22, 0xb6, 0x05, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x54, + 0x6e, 0x66, 0x6f, 0x22, 0xc4, 0x05, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x36, 0x0a, 0x17, 0x74, 0x72, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x5f, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x78, 0x18, 0x01, 0x20, 0x01, 0x28, 0x04, 0x52, 0x15, 0x74, 0x72, 0x61, @@ -612,24 +612,25 @@ var file_transaction_proto_rawDesc = []byte{ 0x69, 0x6e, 0x67, 0x5f, 0x74, 0x78, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x6e, 0x62, 0x6f, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x54, 0x78, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0f, 0x75, 0x6e, 0x62, 0x6f, 0x6e, - 0x64, 0x69, 0x6e, 0x67, 0x54, 0x78, 0x44, 0x61, 0x74, 0x61, 0x12, 0x30, 0x0a, 0x13, 0x62, 0x74, - 0x63, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x48, 0x61, 0x73, - 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x13, 0x62, 0x74, 0x63, 0x44, 0x65, 0x6c, 0x65, - 0x67, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x48, 0x61, 0x73, 0x68, 0x2a, 0xa5, 0x01, 0x0a, - 0x10, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, - 0x65, 0x12, 0x0f, 0x0a, 0x0b, 0x53, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x4f, 0x5f, 0x42, 0x54, 0x43, - 0x10, 0x00, 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x52, 0x4d, 0x45, 0x44, 0x5f, - 0x4f, 0x4e, 0x5f, 0x42, 0x54, 0x43, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x4e, 0x54, - 0x5f, 0x54, 0x4f, 0x5f, 0x42, 0x41, 0x42, 0x59, 0x4c, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x0c, 0x0a, - 0x08, 0x56, 0x45, 0x52, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x44, - 0x45, 0x4c, 0x45, 0x47, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, - 0x10, 0x04, 0x12, 0x1e, 0x0a, 0x1a, 0x55, 0x4e, 0x42, 0x4f, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, - 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x52, 0x4d, 0x45, 0x44, 0x5f, 0x4f, 0x4e, 0x5f, 0x42, 0x54, 0x43, - 0x10, 0x05, 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x50, 0x45, 0x4e, 0x54, 0x5f, 0x4f, 0x4e, 0x5f, 0x42, - 0x54, 0x43, 0x10, 0x06, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, - 0x6f, 0x6d, 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, - 0x6f, 0x2f, 0x62, 0x74, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x64, 0x69, 0x6e, 0x67, 0x54, 0x78, 0x44, 0x61, 0x74, 0x61, 0x12, 0x3e, 0x0a, 0x1a, 0x62, 0x61, + 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x42, 0x54, 0x43, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x54, 0x78, 0x48, 0x61, 0x73, 0x68, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x1a, + 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x42, 0x54, 0x43, 0x44, 0x65, 0x6c, 0x65, 0x67, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x48, 0x61, 0x73, 0x68, 0x2a, 0xa5, 0x01, 0x0a, 0x10, 0x54, + 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x12, + 0x0f, 0x0a, 0x0b, 0x53, 0x45, 0x4e, 0x54, 0x5f, 0x54, 0x4f, 0x5f, 0x42, 0x54, 0x43, 0x10, 0x00, + 0x12, 0x14, 0x0a, 0x10, 0x43, 0x4f, 0x4e, 0x46, 0x49, 0x52, 0x4d, 0x45, 0x44, 0x5f, 0x4f, 0x4e, + 0x5f, 0x42, 0x54, 0x43, 0x10, 0x01, 0x12, 0x13, 0x0a, 0x0f, 0x53, 0x45, 0x4e, 0x54, 0x5f, 0x54, + 0x4f, 0x5f, 0x42, 0x41, 0x42, 0x59, 0x4c, 0x4f, 0x4e, 0x10, 0x02, 0x12, 0x0c, 0x0a, 0x08, 0x56, + 0x45, 0x52, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x03, 0x12, 0x15, 0x0a, 0x11, 0x44, 0x45, 0x4c, + 0x45, 0x47, 0x41, 0x54, 0x49, 0x4f, 0x4e, 0x5f, 0x41, 0x43, 0x54, 0x49, 0x56, 0x45, 0x10, 0x04, + 0x12, 0x1e, 0x0a, 0x1a, 0x55, 0x4e, 0x42, 0x4f, 0x4e, 0x44, 0x49, 0x4e, 0x47, 0x5f, 0x43, 0x4f, + 0x4e, 0x46, 0x49, 0x52, 0x4d, 0x45, 0x44, 0x5f, 0x4f, 0x4e, 0x5f, 0x42, 0x54, 0x43, 0x10, 0x05, + 0x12, 0x10, 0x0a, 0x0c, 0x53, 0x50, 0x45, 0x4e, 0x54, 0x5f, 0x4f, 0x4e, 0x5f, 0x42, 0x54, 0x43, + 0x10, 0x06, 0x42, 0x2c, 0x5a, 0x2a, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, + 0x2f, 0x62, 0x61, 0x62, 0x79, 0x6c, 0x6f, 0x6e, 0x6c, 0x61, 0x62, 0x73, 0x2d, 0x69, 0x6f, 0x2f, + 0x62, 0x74, 0x63, 0x2d, 0x73, 0x74, 0x61, 0x6b, 0x65, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/proto/transaction.proto b/proto/transaction.proto index d2115d1..22ebd95 100644 --- a/proto/transaction.proto +++ b/proto/transaction.proto @@ -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; } diff --git a/staker/events.go b/staker/events.go index fa12cd1..86e7dc2 100644 --- a/staker/events.go +++ b/staker/events.go @@ -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 { diff --git a/staker/stakerapp.go b/staker/stakerapp.go index 52ef828..bc3bc9c 100644 --- a/staker/stakerapp.go +++ b/staker/stakerapp.go @@ -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: @@ -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]( @@ -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) diff --git a/stakerdb/trackedtranactionstore.go b/stakerdb/trackedtranactionstore.go index 444923b..f5ddef5 100644 --- a/stakerdb/trackedtranactionstore.go +++ b/stakerdb/trackedtranactionstore.go @@ -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 @@ -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 } @@ -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) @@ -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 { @@ -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 } diff --git a/stakerservice/service.go b/stakerservice/service.go index ac3dc73..78973c5 100644 --- a/stakerservice/service.go +++ b/stakerservice/service.go @@ -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 } diff --git a/stakerservice/stakerdresponses.go b/stakerservice/stakerdresponses.go index ac52fbb..d8171aa 100644 --- a/stakerservice/stakerdresponses.go +++ b/stakerservice/stakerdresponses.go @@ -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 {