Skip to content
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
2 changes: 1 addition & 1 deletion proto/side/btcbridge/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ message Vault {
// the address to which the voucher is sent
AssetType asset_type = 3;
// version
int32 version = 4;
uint64 version = 4;
}

// ProtocolLimits defines the params related to the the protocol limitations
Expand Down
20 changes: 18 additions & 2 deletions x/btcbridge/keeper/keeper_tss.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,28 @@ func (k Keeper) UpdateVaults(ctx sdk.Context, newVaults []string) {
newVault := &types.Vault{
Address: v,
AssetType: params.Vaults[i].AssetType,
// TODO
Version: 1,
Version: k.IncreaseVaultVersion(ctx),
}

params.Vaults = append(params.Vaults, newVault)
}

k.SetParams(ctx, params)
}

// IncreaseVaultVersion increases the vault version by 1 and starts from 1
// Note: the genesis version is 0
func (k Keeper) IncreaseVaultVersion(ctx sdk.Context) uint64 {
store := ctx.KVStore(k.storeKey)

version := uint64(0)

bz := store.Get(types.VaultVersionKey)
if bz != nil {
version = sdk.BigEndianToUint64(bz)
}

store.Set(types.VaultVersionKey, sdk.Uint64ToBigEndian(version+1))

return version + 1
}
10 changes: 5 additions & 5 deletions x/btcbridge/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ var (
BtcBestBlockHeaderKey = []byte{0x13} // key for the best block height
BtcWithdrawRequestPrefix = []byte{0x14} // prefix for each key to a withdrawal request
BtcWithdrawRequestByTxHashPrefix = []byte{0x15} // prefix for each key to a withdrawal request from tx hash
BtcMintedTxHashKeyPrefix = []byte{0x16} // prefix for each key to a minted tx hash

BtcMintedTxHashKeyPrefix = []byte{0x15} // prefix for each key to a minted tx hash

DKGRequestIDKey = []byte{0x16} // key for the DKG request id
DKGRequestKeyPrefix = []byte{0x17} // prefix for each key to a DKG request
DKGCompletionRequestKeyPrefix = []byte{0x18} // prefix for each key to a DKG completion request
DKGRequestIDKey = []byte{0x20} // key for the DKG request id
DKGRequestKeyPrefix = []byte{0x21} // prefix for each key to a DKG request
DKGCompletionRequestKeyPrefix = []byte{0x22} // prefix for each key to a DKG completion request
VaultVersionKey = []byte{0x23} // key for vault version; default to 0 in the genesis and increased by 1 once updated
)

func Int64ToBytes(number uint64) []byte {
Expand Down
10 changes: 10 additions & 0 deletions x/btcbridge/types/message_complete_dkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ func (m *MsgCompleteDKG) ValidateBasic() error {
return ErrInvalidDKGCompletionRequest
}

vaults := make(map[string]bool)
for _, v := range m.Vaults {
_, err := sdk.AccAddressFromBech32(v)
if err != nil || vaults[v] {
return ErrInvalidDKGCompletionRequest
}

vaults[v] = true
}

if _, err := sdk.ConsAddressFromHex(m.Validator); err != nil {
return ErrInvalidDKGCompletionRequest
}
Expand Down
12 changes: 6 additions & 6 deletions x/btcbridge/types/params.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.