-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathtx.proto
227 lines (207 loc) · 11.4 KB
/
tx.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
syntax = "proto3";
package babylon.btcstaking.v1;
import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/msg/v1/msg.proto";
import "babylon/btcstaking/v1/params.proto";
import "cosmos/staking/v1beta1/staking.proto";
import "babylon/btcstaking/v1/pop.proto";
import "babylon/btcstaking/v1/btcstaking.proto";
option go_package = "github.com/babylonlabs-io/babylon/x/btcstaking/types";
// Msg defines the Msg service.
// TODO: handle unbonding tx with full witness
service Msg {
option (cosmos.msg.v1.service) = true;
// CreateFinalityProvider creates a new finality provider
rpc CreateFinalityProvider(MsgCreateFinalityProvider) returns (MsgCreateFinalityProviderResponse);
// EditFinalityProvider edits an existing finality provider
rpc EditFinalityProvider(MsgEditFinalityProvider) returns (MsgEditFinalityProviderResponse);
// CreateBTCDelegation creates a new BTC delegation
rpc CreateBTCDelegation(MsgCreateBTCDelegation) returns (MsgCreateBTCDelegationResponse);
// AddBTCDelegationInclusionProof adds inclusion proof of a given delegation on BTC chain
rpc AddBTCDelegationInclusionProof(MsgAddBTCDelegationInclusionProof) returns (MsgAddBTCDelegationInclusionProofResponse);
// AddCovenantSigs handles signatures from a covenant member
rpc AddCovenantSigs(MsgAddCovenantSigs) returns (MsgAddCovenantSigsResponse);
// BTCUndelegate handles a signature on unbonding tx from its delegator
rpc BTCUndelegate(MsgBTCUndelegate) returns (MsgBTCUndelegateResponse);
// SelectiveSlashingEvidence handles the evidence of selective slashing launched
// by a finality provider
rpc SelectiveSlashingEvidence(MsgSelectiveSlashingEvidence) returns (MsgSelectiveSlashingEvidenceResponse);
// UpdateParams updates the btcstaking module parameters.
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}
// MsgCreateFinalityProvider is the message for creating a finality provider
message MsgCreateFinalityProvider {
option (cosmos.msg.v1.signer) = "addr";
// addr defines the address of the finality provider that will receive
// the commissions to all the delegations.
string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// description defines the description terms for the finality provider
cosmos.staking.v1beta1.Description description = 2;
// commission defines the commission rate of the finality provider
string commission = 3 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec"
];
// btc_pk is the Bitcoin secp256k1 PK of this finality provider
// the PK follows encoding in BIP-340 spec
bytes btc_pk = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// pop is the proof of possession of btc_pk over the FP signer address.
ProofOfPossessionBTC pop = 5;
// consumer_id is the ID of the consumer
// If it's empty, it's assumed to be Babylon's chain id
string consumer_id = 6;
}
// MsgCreateFinalityProviderResponse is the response for MsgCreateFinalityProvider
message MsgCreateFinalityProviderResponse {}
// MsgEditFinalityProvider is the message for editing an existing finality provider
message MsgEditFinalityProvider {
option (cosmos.msg.v1.signer) = "addr";
// addr the address of the finality provider that whishes to edit his information.
string addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// btc_pk is the Bitcoin secp256k1 PK of the finality provider to be edited
bytes btc_pk = 2;
// description defines the updated description terms for the finality provider
cosmos.staking.v1beta1.Description description = 3;
// commission defines the updated commission rate of the finality provider
string commission = 4 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec"
];
}
// MsgEditFinalityProviderResponse is the response for MsgEditFinalityProvider
message MsgEditFinalityProviderResponse {}
// MsgCreateBTCDelegation is the message for creating a BTC delegation
message MsgCreateBTCDelegation {
option (cosmos.msg.v1.signer) = "staker_addr";
// staker_addr is the address to receive rewards from BTC delegation.
string staker_addr = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// pop is the proof of possession of btc_pk by the staker_addr.
ProofOfPossessionBTC pop = 2;
// btc_pk is the Bitcoin secp256k1 PK of the BTC delegator
bytes btc_pk = 3 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// fp_btc_pk_list is the list of Bitcoin secp256k1 PKs of the finality providers, if there is more than one
// finality provider pk it means that delegation is re-staked
repeated bytes fp_btc_pk_list = 4 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// staking_time is the time lock used in staking transaction
uint32 staking_time = 5;
// staking_value is the amount of satoshis locked in staking output
int64 staking_value = 6;
// staking_tx is a bitcoin staking transaction i.e transaction that locks funds
bytes staking_tx = 7 ;
// staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain
InclusionProof staking_tx_inclusion_proof = 8;
// slashing_tx is the slashing tx
// Note that the tx itself does not contain signatures, which are off-chain.
bytes slashing_tx = 9 [ (gogoproto.customtype) = "BTCSlashingTx" ];
// delegator_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk).
// It will be a part of the witness for the staking tx output.
// The staking tx output further needs signatures from covenant and finality provider in
// order to be spendable.
bytes delegator_slashing_sig = 10 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ];
// unbonding_time is the time lock used when funds are being unbonded. It is be used in:
// - unbonding transaction, time lock spending path
// - staking slashing transaction, change output
// - unbonding slashing transaction, change output
// It must be smaller than math.MaxUInt16 and larger that max(MinUnbondingTime, CheckpointFinalizationTimeout)
uint32 unbonding_time = 11;
// fields related to unbonding transaction
// unbonding_tx is a bitcoin unbonding transaction i.e transaction that spends
// staking output and sends it to the unbonding output
bytes unbonding_tx = 12;
// unbonding_value is amount of satoshis locked in unbonding output.
// NOTE: staking_value and unbonding_value could be different because of the difference between the fee for staking tx and that for unbonding
int64 unbonding_value = 13;
// unbonding_slashing_tx is the slashing tx which slash unbonding contract
// Note that the tx itself does not contain signatures, which are off-chain.
bytes unbonding_slashing_tx = 14 [ (gogoproto.customtype) = "BTCSlashingTx" ];
// delegator_unbonding_slashing_sig is the signature on the slashing tx by the delegator (i.e., SK corresponding to btc_pk).
bytes delegator_unbonding_slashing_sig = 15 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ];
}
// MsgCreateBTCDelegationResponse is the response for MsgCreateBTCDelegation
message MsgCreateBTCDelegationResponse {}
// MsgAddBTCDelegationInclusionProof is the message for adding proof of inclusion of BTC delegation on BTC chain
message MsgAddBTCDelegationInclusionProof {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 2;
// staking_tx_inclusion_proof is the inclusion proof of the staking tx in BTC chain
InclusionProof staking_tx_inclusion_proof = 3;
}
// MsgAddBTCDelegationInclusionProofResponse is the response for MsgAddBTCDelegationInclusionProof
message MsgAddBTCDelegationInclusionProofResponse {}
// MsgAddCovenantSigs is the message for handling signatures from a covenant member
message MsgAddCovenantSigs {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
// pk is the BTC public key of the covenant member
bytes pk = 2 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340PubKey" ];
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 3;
// sigs is a list of adaptor signatures of the covenant
// the order of sigs should respect the order of finality providers
// of the corresponding delegation
repeated bytes slashing_tx_sigs = 4;
// unbonding_tx_sig is the signature of the covenant on the unbonding tx submitted to babylon
// the signature follows encoding in BIP-340 spec
bytes unbonding_tx_sig = 5 [ (gogoproto.customtype) = "github.com/babylonlabs-io/babylon/types.BIP340Signature" ];
// slashing_unbonding_tx_sigs is a list of adaptor signatures of the covenant
// on slashing tx corresponding to unbonding tx submitted to babylon
// the order of sigs should respect the order of finality providers
// of the corresponding delegation
repeated bytes slashing_unbonding_tx_sigs = 6;
}
// MsgAddCovenantSigsResponse is the response for MsgAddCovenantSigs
message MsgAddCovenantSigsResponse {}
// MsgBTCUndelegate is the message for handling signature on unbonding tx
// from its delegator. This signature effectively proves that the delegator
// wants to unbond this BTC delegation
message MsgBTCUndelegate {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 2;
// stake_spending_tx is a bitcoin transaction that spends the staking transaction
// i.e it has staking output as an input
bytes stake_spending_tx = 3;
// spend_spending_tx_inclusion_proof is the proof of inclusion of the
// stake_spending_tx in the BTC chain
InclusionProof stake_spending_tx_inclusion_proof = 4;
}
// MsgBTCUndelegateResponse is the response for MsgBTCUndelegate
message MsgBTCUndelegateResponse {}
// MsgSelectiveSlashingEvidence is the message for handling evidence of selective slashing
// launched by a finality provider
message MsgSelectiveSlashingEvidence {
option (cosmos.msg.v1.signer) = "signer";
string signer = 1;
// staking_tx_hash is the hash of the staking tx.
// It uniquely identifies a BTC delegation
string staking_tx_hash = 2;
// recovered_fp_btc_sk is the BTC SK of the finality provider who
// launches the selective slashing offence. The SK is recovered by
// using a covenant adaptor signature and the corresponding Schnorr
// signature
bytes recovered_fp_btc_sk = 3;
}
// MsgSelectiveSlashingEvidenceResponse is the response for MsgSelectiveSlashingEvidence
message MsgSelectiveSlashingEvidenceResponse {}
// MsgUpdateParams defines a message for updating btcstaking module parameters.
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
// authority is the address of the governance account.
// just FYI: cosmos.AddressString marks that this field should use type alias
// for AddressString instead of string, but the functionality is not yet implemented
// in cosmos-proto
string authority = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
// params defines the finality parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [(gogoproto.nullable) = false];
}
// MsgUpdateParamsResponse is the response to the MsgUpdateParams message.
message MsgUpdateParamsResponse {}