From 9b79db12115dd65e15385b216a4e04d816e03ee2 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Fri, 20 Dec 2024 18:38:20 +0100 Subject: [PATCH 1/4] bump babylon v1 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index e9ee1f2..fd776bc 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( cosmossdk.io/errors v1.0.1 cosmossdk.io/math v1.4.0 github.com/avast/retry-go/v4 v4.5.1 - github.com/babylonlabs-io/babylon v0.18.0 + github.com/babylonlabs-io/babylon v1.0.0-rc.1 github.com/babylonlabs-io/networks/parameters v0.2.2 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.2 diff --git a/go.sum b/go.sum index d363731..e71d683 100644 --- a/go.sum +++ b/go.sum @@ -1432,8 +1432,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k= github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/babylonlabs-io/babylon v0.18.0 h1:phMY/GiR9N5MpD3XCmvyPpZkc1I3kTM9yX+Cf0h3OnU= -github.com/babylonlabs-io/babylon v0.18.0/go.mod h1:sT+KG2U+M0tDMNZZ2L5CwlXX0OpagGEs56BiWXqaZFw= +github.com/babylonlabs-io/babylon v1.0.0-rc.1 h1:esV0UJ1TmXfVkfKWOee/2ny+GMiqZXNni8f2H4ASD38= +github.com/babylonlabs-io/babylon v1.0.0-rc.1/go.mod h1:B8ma8IjGUEKhmoRfwv60Qa7DtUXssCgtmD89huQ4+5I= github.com/babylonlabs-io/networks/parameters v0.2.2 h1:TCu39fZvjX5f6ZZrjhYe54M6wWxglNewuKu56yE+zrc= github.com/babylonlabs-io/networks/parameters v0.2.2/go.mod h1:iEJVOzaLsE33vpP7J4u+CRGfkSIfErUAwRmgCFCBpyI= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= From a285a19339b3896916915c1aecbb6d80bfe730b5 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Fri, 20 Dec 2024 18:39:57 +0100 Subject: [PATCH 2/4] change log update --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7810811..44d0cbc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,6 +35,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## Unreleased +* [#108](https://github.com/babylonlabs-io/btc-staker/pull/108) Bump babylon to v1.0.0-rc.1 + +## v0.13.0 + * [#102](https://github.com/babylonlabs-io/btc-staker/pull/102) Bump babylon v18 and fix incompatibilities From 224de86f13376383b71b217657ae7eb22d7725b8 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Fri, 20 Dec 2024 18:54:21 +0100 Subject: [PATCH 3/4] adapt params retireval --- babylonclient/babyloncontroller.go | 6 +++--- babylonclient/interface.go | 5 +++++ staker/stakerapp.go | 9 ++++++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/babylonclient/babyloncontroller.go b/babylonclient/babyloncontroller.go index 406c5ca..3ba293c 100644 --- a/babylonclient/babyloncontroller.go +++ b/babylonclient/babyloncontroller.go @@ -1004,13 +1004,13 @@ func (bc *BabylonController) InsertSpvProofs(submitter string, proofs []*btcctyp return res, nil } -func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfoResponse, error) { +func (bc *BabylonController) QueryBtcLightClientTipHeight() (uint32, error) { res, err := bc.bbnClient.QueryClient.BTCHeaderChainTip() if err != nil { - return nil, fmt.Errorf("failed to query BTC tip: %w", err) + return 0, fmt.Errorf("failed to query BTC tip: %w", err) } - return res.Header, nil + return res.Header.Height, nil } func (bc *BabylonController) ActivateDelegation( diff --git a/babylonclient/interface.go b/babylonclient/interface.go index f045b5c..c75f963 100644 --- a/babylonclient/interface.go +++ b/babylonclient/interface.go @@ -85,6 +85,7 @@ type BabylonClient interface { IsTxAlreadyPartOfDelegation(stakingTxHash *chainhash.Hash) (bool, error) QueryDelegationInfo(stakingTxHash *chainhash.Hash) (*DelegationInfo, error) GetLatestBlockHeight() (uint64, error) + QueryBtcLightClientTipHeight() (uint32, error) } type MockBabylonClient struct { @@ -227,3 +228,7 @@ func GetMockClient() *MockBabylonClient { ActiveFinalityProvider: &vi, } } + +func (bc *MockBabylonClient) QueryBtcLightClientTipHeight() (uint32, error) { + return 0, nil +} diff --git a/staker/stakerapp.go b/staker/stakerapp.go index 9e6b70d..da9efbb 100644 --- a/staker/stakerapp.go +++ b/staker/stakerapp.go @@ -977,7 +977,14 @@ func (app *App) retrieveExternalDelegationData( var params *cl.StakingParams if inclusionInfo == nil { - p, err := app.babylonClient.Params() + // chose params as babylon would through tip of btc light client + tipHeight, err := app.babylonClient.QueryBtcLightClientTipHeight() + + if err != nil { + return nil, err + } + + p, err := app.babylonClient.ParamsByBtcHeight(tipHeight) if err != nil { return nil, err From 9e81b0e2457fe2d14d6d773b608cc139ba4727e2 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Fri, 20 Dec 2024 18:57:48 +0100 Subject: [PATCH 4/4] fix linter --- babylonclient/interface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/babylonclient/interface.go b/babylonclient/interface.go index c75f963..34c7a57 100644 --- a/babylonclient/interface.go +++ b/babylonclient/interface.go @@ -229,6 +229,6 @@ func GetMockClient() *MockBabylonClient { } } -func (bc *MockBabylonClient) QueryBtcLightClientTipHeight() (uint32, error) { +func (m *MockBabylonClient) QueryBtcLightClientTipHeight() (uint32, error) { return 0, nil }