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

Add staking tx to the creation event #273

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [#270](https://github.com/babylonlabs-io/babylon/pull/270) Validate there is only
one finality provider key in the staking request

### API Breaking

- [#273](https://github.com/babylonlabs-io/babylon/pull/273) Add full staking tx to BTC delegation creation event
## v0.16.0

### Improvements
Expand Down
26 changes: 10 additions & 16 deletions proto/babylon/btcstaking/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,27 @@ enum FinalityProviderStatus {
// EventBTCDelegationCreated is the event emitted when a BTC delegation is created
// on the Babylon chain
message EventBTCDelegationCreated {
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// staking_output_pk_script is the hex encoded PK script of the staking output
string staking_output_pk_script = 2 [(amino.dont_omitempty) = true];
// staking_tx_hex is the hex encoded staking tx
string staking_tx_hex = 1 [(amino.dont_omitempty) = true];
// staking_output_index is the index of the staking output in the staking tx
string staking_output_index = 3 [(amino.dont_omitempty) = true];
string staking_output_index = 2 [(amino.dont_omitempty) = true];
// version of the params used to validate the delegation
string params_version = 4 [(amino.dont_omitempty) = true];
string params_version = 3 [(amino.dont_omitempty) = true];
// finality_provider_btc_pks_hex is the list of hex str of Bitcoin secp256k1 PK of
// the finality providers that this BTC delegation delegates to
// the PK follows encoding in BIP-340 spec
repeated string finality_provider_btc_pks_hex = 5 [(amino.dont_omitempty) = true];
repeated string finality_provider_btc_pks_hex = 4 [(amino.dont_omitempty) = true];
// staker_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the staker that
// creates this BTC delegation the PK follows encoding in BIP-340 spec
string staker_btc_pk_hex = 6 [(amino.dont_omitempty) = true];
string staker_btc_pk_hex = 5 [(amino.dont_omitempty) = true];
// staking_time is the timelock of the staking tx specified in the BTC script
string staking_time = 7 [(amino.dont_omitempty) = true];
// staking_amount is the total amount of BTC stake in this delegation
// quantified in satoshi
string staking_amount = 8 [(amino.dont_omitempty) = true];
string staking_time = 6 [(amino.dont_omitempty) = true];
// unbonding_time is the time is timelock on unbonding tx chosen by the staker
string unbonding_time = 9 [(amino.dont_omitempty) = true];
string unbonding_time = 7 [(amino.dont_omitempty) = true];
// unbonding_tx is hex encoded bytes of the unsigned unbonding tx
string unbonding_tx = 10 [(amino.dont_omitempty) = true];
string unbonding_tx = 8 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 11 [(amino.dont_omitempty) = true];
string new_state = 9 [(amino.dont_omitempty) = true];
}

// EventCovenantSignatureReceived is the event emitted when a covenant committee
Expand Down
1 change: 0 additions & 1 deletion x/btcstaking/keeper/btc_delegations.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ func (k Keeper) AddBTCDelegation(
k.setBTCDelegation(ctx, btcDel)

if err := ctx.EventManager().EmitTypedEvents(types.NewBtcDelCreationEvent(
stakingTxHash.String(),
btcDel,
)); err != nil {
panic(fmt.Errorf("failed to emit events for the new pending BTC delegation: %w", err))
Expand Down
5 changes: 1 addition & 4 deletions x/btcstaking/types/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,15 @@ func NewInclusionProofEvent(
}

func NewBtcDelCreationEvent(
stakingTxHash string,
btcDel *BTCDelegation,
) *EventBTCDelegationCreated {
return &EventBTCDelegationCreated{
StakingTxHash: stakingTxHash,
StakingOutputPkScript: hex.EncodeToString(btcDel.MustGetStakingTx().TxOut[btcDel.StakingOutputIdx].PkScript),
StakingTxHex: hex.EncodeToString(btcDel.StakingTx),
StakingOutputIndex: strconv.FormatUint(uint64(btcDel.StakingOutputIdx), 10),
ParamsVersion: strconv.FormatUint(uint64(btcDel.ParamsVersion), 10),
FinalityProviderBtcPksHex: btcDel.FinalityProviderKeys(),
StakerBtcPkHex: btcDel.BtcPk.MarshalHex(),
StakingTime: strconv.FormatUint(uint64(btcDel.StakingTime), 10),
StakingAmount: strconv.FormatUint(btcDel.TotalSat, 10),
UnbondingTime: strconv.FormatUint(uint64(btcDel.UnbondingTime), 10),
UnbondingTx: hex.EncodeToString(btcDel.BtcUndelegation.UnbondingTx),
NewState: BTCDelegationStatus_PENDING.String(),
Expand Down
Loading