-
Notifications
You must be signed in to change notification settings - Fork 40
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
chore: Improve external events format #169
Changes from all commits
ba417db
31613cd
066dd51
ee0c876
4fb9bfd
9674caa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
@@ -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 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gitferry just to confirm my assumption: we’re splitting the unbonded state into two separate events for natural unbonding and the unbonding path. This means the API no longer needs to differentiate between a transaction event and a block event. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, they are separate events |
||
// 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]; | ||
} |
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.
why does commission is none-optional in the edit mode?
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.
commission is a required field when a fp is registered on babylon
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.
sure, but for the edit event, why does it need to be here? if FP's commission was not updated, we don't emit it, right?