Skip to content

Commit

Permalink
backport: Improve external events format (#169) (#182)
Browse files Browse the repository at this point in the history
This is a manual backport as the automatic backport failed
  • Loading branch information
gitferry authored Oct 11, 2024
1 parent 43499da commit 4c7306b
Show file tree
Hide file tree
Showing 6 changed files with 1,299 additions and 580 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## Unreleased

### Improvements

* [#169](https://github.com/babylonlabs-io/babylon/pull/169) Improve external events format and update events doc

## v0.12.0

### State Machine Breaking
Expand Down
149 changes: 79 additions & 70 deletions proto/babylon/btcstaking/v1/events.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,46 @@ import "gogoproto/gogo.proto";
import "cosmos/staking/v1beta1/staking.proto";
import "babylon/btcstaking/v1/btcstaking.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types";

// EventFinalityProviderCreated is the event emitted when a finality provider is created
message EventFinalityProviderCreated {
// btc_pk is the Bitcoin secp256k1 PK of this finality provider
// the PK follows encoding in BIP-340 spec
bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// addr is the address to receive commission from delegations.
string addr = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// commission defines the commission rate of the finality provider.
string commission = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec"
];
// description defines the description terms for the finality provider.
cosmos.staking.v1beta1.Description description = 4;
// btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider
string btc_pk_hex = 1 [(amino.dont_omitempty) = true];
// addr is the babylon address to receive commission from delegations.
string addr = 2 [(amino.dont_omitempty) = true];
// commission defines the commission rate of the finality provider in decimals.
string commission = 3 [(amino.dont_omitempty) = true];
// moniker defines a human-readable name for the finality provider.
string moniker = 4;
// identity defines an optional identity signature (ex. UPort or Keybase).
string identity = 5;
// website defines an optional website link.
string website = 6;
// security_contact defines an optional email for security contact.
string security_contact = 7;
// details define other optional details.
string details = 8;
}

// EventFinalityProviderEdited is the event emitted when a finality provider is edited
message EventFinalityProviderEdited {
// btc_pk is the Bitcoin secp256k1 PK of this finality provider
// the PK follows encoding in BIP-340 spec
bytes btc_pk = 1 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// commission defines the commission rate of the finality provider.
string commission = 2 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec"
];
// description defines the description terms for the finality provider.
cosmos.staking.v1beta1.Description description = 3;
// btc_pk_hex is the hex string of Bitcoin secp256k1 PK of this finality provider
string btc_pk_hex = 1 [(amino.dont_omitempty) = true];
// commission defines the commission rate of the finality provider in decimals.
string commission = 2 [(amino.dont_omitempty) = true];
// moniker defines a human-readable name for the finality provider.
string moniker = 3;
// identity defines an optional identity signature (ex. UPort or Keybase).
string identity = 4;
// website defines an optional website link.
string website = 5;
// security_contact defines an optional email for security contact.
string security_contact = 6;
// details define other optional details.
string details = 7;
}

// EventBTCDelegationStateUpdate is the event emitted when a BTC delegation's state is
Expand Down Expand Up @@ -94,15 +103,6 @@ message EventPowerDistUpdate {
}
}

message EventFinalityProviderStatusChange {
// btc_pk is the BTC public key of the finality provider
string btc_pk = 1;
// new_status is the new status that the finality provider
// is transitioned to
FinalityProviderStatus new_status = 2;
}

// FinalityProviderStatus is the status of a finality provider.
// A finality provider starts with status INACTIVE once registered.
// Possible status transitions are when:
// 1. it has accumulated sufficient delegations and has
Expand All @@ -119,103 +119,112 @@ message EventFinalityProviderStatusChange {
// ACTIVE -> INACTIVE.
// Note that it is impossible for a SLASHED finality provider to
// transition to other status
message EventFinalityProviderStatusChange {
// btc_pk is the BTC public key of the finality provider
string btc_pk = 1 [(amino.dont_omitempty) = true];
// new_state is the status that the finality provider
// is transitioned to, following FinalityProviderStatus
string new_state = 2 [(amino.dont_omitempty) = true];
}

// FinalityProviderStatus is the status of a finality provider.
enum FinalityProviderStatus {
// STATUS_INACTIVE defines a finality provider that does not have sufficient
// FINALITY_PROVIDER_STATUS_INACTIVE defines a finality provider that does not have sufficient
// delegations or does not have timestamped public randomness.
STATUS_INACTIVE = 0;
// STATUS_ACTIVE defines a finality provider that have sufficient delegations
FINALITY_PROVIDER_STATUS_INACTIVE = 0;
// FINALITY_PROVIDER_STATUS_ACTIVE defines a finality provider that have sufficient delegations
// and have timestamped public randomness.
STATUS_ACTIVE = 1;
// STATUS_JAILED defines a finality provider that is jailed due to downtime
STATUS_JAILED = 2;
// STATUS_SLASHED defines a finality provider that is slashed due to double-sign
STATUS_SLASHED = 3;
FINALITY_PROVIDER_STATUS_ACTIVE = 1;
// FINALITY_PROVIDER_STATUS_JAILED defines a finality provider that is jailed due to downtime
FINALITY_PROVIDER_STATUS_JAILED = 2;
// FINALITY_PROVIDER_STATUS_SLASHED defines a finality provider that is slashed due to double-sign
FINALITY_PROVIDER_STATUS_SLASHED = 3;
}

// 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;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// version of the params used to validate the delegation
uint32 params_version = 2;
string params_version = 2 [(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 = 3;
repeated string finality_provider_btc_pks_hex = 3 [(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 = 4;
string staker_btc_pk_hex = 4 [(amino.dont_omitempty) = true];
// staking_time is the timelock of the staking tx specified in the BTC script
uint32 staking_time = 5;
string staking_time = 5 [(amino.dont_omitempty) = true];
// staking_amount is the total amount of BTC stake in this delegation
// quantified in satoshi
uint64 staking_amount = 6;
string staking_amount = 6 [(amino.dont_omitempty) = true];
// unbonding_time is the time is timelock on unbonding tx chosen by the staker
uint32 unbonding_time = 7;
string unbonding_time = 7 [(amino.dont_omitempty) = true];
// unbonding_tx is hex encoded bytes of the unsigned unbonding tx
string unbonding_tx = 8;
// state of the BTC delegation
BTCDelegationStatus state = 9;
string unbonding_tx = 8 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 9 [(amino.dont_omitempty) = true];
}

// EventCovenantSignatureRecevied is the event emitted when a covenant committee
// EventCovenantSignatureReceived is the event emitted when a covenant committee
// sends valid covenant signatures for a BTC delegation
message EventCovenantSignatureRecevied{
message EventCovenantSignatureReceived{
// staking_tx_hash is the hash of the staking identifing the BTC delegation
// that this covenant signature is for
string staking_tx_hash = 1;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// covenant_btc_pk_hex is the hex str of Bitcoin secp256k1 PK of the
// covnenat committee that send the signature
string covenant_btc_pk_hex = 2;
string covenant_btc_pk_hex = 2 [(amino.dont_omitempty) = true];
// covenant_unbonding_signature_hex is the hex str of the BIP340 Schnorr
// signature of the covenant committee on the unbonding tx
string covenant_unbonding_signature_hex = 3;
string covenant_unbonding_signature_hex = 3 [(amino.dont_omitempty) = true];
}

// EventCovenantQuroumReached is the event emitted quorum of covenant committee
// EventCovenantQuorumReached is the event emitted quorum of covenant committee
// is reached for a BTC delegation
message EventCovenantQuroumReached {
message EventCovenantQuorumReached {
// staking_tx_hash is the hash of the staking identifing the BTC delegation
// that this covenant signature is for
string staking_tx_hash = 1;
// state of the BTC delegation
BTCDelegationStatus state = 2;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 2 [(amino.dont_omitempty) = true];
}

// EventBTCDelegationInclusionProofReceived is the event emitted when a BTC delegation
// inclusion proof is received
message EventBTCDelegationInclusionProofReceived {
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 1;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// start_height is the start BTC height of the BTC delegation
// it is the start BTC height of the timelock
uint64 start_height = 2;
string start_height = 2 [(amino.dont_omitempty) = true];
// end_height is the end height of the BTC delegation
// it is calculated by end_height = start_height + staking_time
uint64 end_height = 3;
// state of the BTC delegation
BTCDelegationStatus state = 4;
string end_height = 3 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 4 [(amino.dont_omitempty) = true];
}

// EventBTCDelgationUnbondedEarly is the event emitted when a BTC delegation
// is unbonded by staker sending unbonding tx to BTC
message EventBTCDelgationUnbondedEarly {
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 1;
// state of the BTC delegation
BTCDelegationStatus state = 2;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 2 [(amino.dont_omitempty) = true];
}

// EventBTCDelegationExpired is the event emitted when a BTC delegation
// is unbonded by expiration of the staking tx timelock
message EventBTCDelegationExpired {
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 1;
// state of the BTC delegation
BTCDelegationStatus state = 2;
string staking_tx_hash = 1 [(amino.dont_omitempty) = true];
// new_state of the BTC delegation
string new_state = 2 [(amino.dont_omitempty) = true];
}
Loading

0 comments on commit 4c7306b

Please sign in to comment.