Skip to content
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: pull main to feat 457 #465

Merged
merged 103 commits into from
Jan 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
2207f55
integration: set up `x/btcstkconsumer` module (#206)
SebastianElvis Mar 13, 2024
88f891c
F/consumer chain registry (#205)
maurolacy Mar 13, 2024
f4b88ab
F/consumer chain registry 2 (#209)
maurolacy Mar 13, 2024
873cfce
F/register codecs (#210)
maurolacy Mar 15, 2024
7928f66
F/consumer FP registry (#216)
maurolacy Mar 20, 2024
a4d244c
F/consumer fp registry 2 (#220)
maurolacy Mar 20, 2024
65657d1
handling restaked BTC delegations to consumer FPs (#222)
SebastianElvis Mar 22, 2024
0c5d6aa
F/consumer chain cli (#221)
maurolacy Mar 22, 2024
76efc0d
Update CHANGELOG
Mar 22, 2024
ce164ea
fix: only calculating Babylon FPs for FP set rotation (#223)
SebastianElvis Mar 25, 2024
5c15e74
Update CHANGELOG
Mar 25, 2024
b98b20e
fix
SebastianElvis Apr 2, 2024
0a6e9f8
R/consumer chain 2 (#224)
maurolacy Apr 3, 2024
c94b5f5
linting validateRestakedFPs
SebastianElvis Apr 16, 2024
4c1e0d5
proto: define IBC packet formats for PoS integration (#229)
SebastianElvis Apr 22, 2024
56b21f4
zoneconcierge: let zoneconcierge hold a pointer to btcstaking module …
SebastianElvis Apr 22, 2024
4601ff5
tests: Add pos-integration E2E Tests (#225)
gusin13 Apr 22, 2024
27f7072
chore: fix some proto formats for IBC packets (#234)
SebastianElvis Apr 25, 2024
78120b3
chore: rename chain to consumer for PoS integration (#233)
SebastianElvis Apr 25, 2024
038943a
btcstkconsumer: separate IBC packet for provider / consumer (#237)
SebastianElvis Apr 30, 2024
8f134e1
feat: Store btcstaking events in kv store and send IBC packet (#235)
gusin13 Apr 30, 2024
1ed7149
tests: btcstaking events e2e tests (#240)
gusin13 May 16, 2024
61ef003
release v0.2.0 rc0 (#245)
SebastianElvis May 17, 2024
49663ec
cd: Allows base/consumer-chain-support branch to run push_docker job …
hiepmai-babylonchain May 20, 2024
5f8413b
btcstkconsumer: RPC functions for BTC staking consumer module (#247)
SebastianElvis May 20, 2024
5701ec9
Fix/babylon update (#253)
maurolacy May 28, 2024
a0ec504
tests: Add undelegation and fp voting power test cases (#254)
gusin13 May 29, 2024
5d00627
feat: Add `cosmwasm_2_0` to `wasmCapabilities` (#255)
lesterli Jun 13, 2024
db66211
feat: Add Grpc querier (#257)
lesterli Jun 18, 2024
265678f
chore: remove aarch64 wasm (#261)
lesterli Jun 20, 2024
fdd9040
Fix rebase error
Jul 8, 2024
e57fefc
Fix rebase error / Simplify testutil btcstaking helpers
Jul 8, 2024
253dab4
fix: panic to merge proto files (#264)
lesterli Jul 5, 2024
e7658c2
U/contracts 0.7 (#270)
maurolacy Jul 10, 2024
0a646a3
Fix: Add stker_addr to active btc delegation
Jul 10, 2024
a6a6fc7
Update contracts from rebase branch
Jul 11, 2024
6f1b119
Fix: btc staking integration rebase errors
Jul 12, 2024
8531b8b
Fix: ExecCmd vs ExecTxCmd inconsistency
Jul 12, 2024
6c9ffa0
Fix in passing: docker warning
Jul 12, 2024
d1afabf
Fix syntax
Jul 12, 2024
d63dc74
proto-lint
Jul 12, 2024
33db0a6
proto-gen
Jul 12, 2024
b924ff0
Sanitize code path to avoid gosec warning
Jul 12, 2024
735e248
Increase Go min version to 1.22
Jul 12, 2024
fead9dc
Increase go version in CI
Jul 12, 2024
b83688b
Increase Go version in babylon container
Jul 12, 2024
30f2a15
Workaround consumer and babylon FP creation for staking integration t…
Jul 13, 2024
d1c5b08
Revert "Workaround consumer and babylon FP creation for staking integ…
Jul 15, 2024
a0e86bc
Comment pop.Verify out
Jul 15, 2024
dbf026c
fix fp gen
SebastianElvis Jul 15, 2024
5cdf5bb
fix gosec
SebastianElvis Jul 15, 2024
3d8f190
chore: rename del Babylon address in e2e (#273)
SebastianElvis Jul 17, 2024
6ecfdf4
Merge branch 'dev' into try-rebase-dev
SebastianElvis Jul 30, 2024
ce31233
fix compile
SebastianElvis Jul 30, 2024
d77e0cb
fix all tests
SebastianElvis Jul 30, 2024
74a24c9
Merge pull request #1 from babylonlabs-io/try-rebase-dev
SebastianElvis Aug 1, 2024
bd458da
feat: Automatic consumer registration (#11)
gusin13 Aug 14, 2024
20c5405
Merge branch 'dev' into merge-dev
SebastianElvis Aug 16, 2024
b03a1d8
fix e2e
SebastianElvis Aug 16, 2024
6bcadbc
Merge pull request #13 from babylonlabs-io/merge-dev-1
SebastianElvis Aug 17, 2024
81ee356
Add Consumer packet data defs / gens (#15)
maurolacy Aug 28, 2024
7942dae
tests: bcd setup in e2e (#57)
gusin13 Sep 11, 2024
35a5a1b
feat: Babylon FP cascaded slashing (#69)
gusin13 Sep 17, 2024
d6b39e8
Merge branch 'main' into try-rebase
SebastianElvis Sep 19, 2024
59a2486
fix compile
SebastianElvis Sep 19, 2024
747ca8e
feat(ADR-025): Enable jailing and unjailing (#80)
gitferry Sep 19, 2024
063241e
fix compile/tests
SebastianElvis Sep 20, 2024
bca42f1
accommodate timestamped pub rand for e2e
SebastianElvis Sep 20, 2024
0e661b3
Merge pull request #83 from babylonlabs-io/try-rebase
SebastianElvis Sep 23, 2024
a6f728b
Merge branch 'main' into base/consumer-chain-support
SebastianElvis Sep 23, 2024
a98269d
feat: Consumer FP cascaded slashing (#85)
gusin13 Sep 25, 2024
3520b05
f/Better IBC transfer tests (#128)
maurolacy Oct 4, 2024
8ee2c85
chore: gh sync workflow from main to base (#133)
gusin13 Oct 15, 2024
d10dd40
Merge branch 'main' into rebase-devnet-5
SebastianElvis Nov 14, 2024
540d59f
fix conflicts
SebastianElvis Nov 14, 2024
1be1c2b
fix compile
SebastianElvis Nov 15, 2024
098751b
Merge branch 'main' into rebase-devnet-5
SebastianElvis Nov 18, 2024
579d66c
fix tests and disable v1 upgrade e2e
SebastianElvis Nov 20, 2024
3aa1afc
Merge pull request #266 from babylonlabs-io/rebase-devnet-5
SebastianElvis Nov 20, 2024
ad3e100
F/consumer rewards e2e (#301)
maurolacy Nov 27, 2024
4898d8d
zoneconcierge: permissioned integration (#291)
SebastianElvis Dec 3, 2024
9300461
feat: add the slashing msg handler for op consumer fp (#327)
lesterli Dec 7, 2024
72654c8
e2e: remove e2e related to BTC staking integration (#339)
SebastianElvis Dec 13, 2024
e901f1c
fix: remove unused deps in `.proto` files (#355)
lesterli Dec 18, 2024
92ed24c
Merge branch 'main' into merge-main-to-base-2025
SebastianElvis Jan 13, 2025
e2651ab
fix compile and tests
SebastianElvis Jan 13, 2025
c06b2fe
fix lint
SebastianElvis Jan 13, 2025
abeef54
Merge pull request #399 from babylonlabs-io/merge-main-to-base-2025
filippos47 Jan 14, 2025
cbfb705
Merge branch 'main' into merge-base-2025-2
SebastianElvis Jan 14, 2025
9fa494b
Merge pull request #403 from babylonlabs-io/merge-base-2025-2
filippos47 Jan 14, 2025
873f123
fix: fix comments to the base branch (#418)
SebastianElvis Jan 17, 2025
eaf20a1
fix: fix comments to the base branch 2 (#424)
SebastianElvis Jan 22, 2025
3221f11
Merge branch 'main' into merge-main-to-base-0122
SebastianElvis Jan 22, 2025
3273ea8
Merge pull request #432 from babylonlabs-io/merge-main-to-base-0122
filippos47 Jan 22, 2025
10905e7
Merge pull request #402 from babylonlabs-io/base/consumer-chain-support
filippos47 Jan 23, 2025
2b8c528
chore: remove `cosmos/relayer` dependency (#429)
Lazar955 Jan 23, 2025
abc2272
chore: fix flaky test `FuzzCreateBTCDelegationWithParamsFromBtcHeight…
KonradStaniec Jan 27, 2025
1038c81
fix: swagger doc gen incentive v1 (#443)
RafilxTenfen Jan 27, 2025
367f8c0
Reject forks if the first header is already known (#445)
KonradStaniec Jan 27, 2025
02612f9
backport changelog update (#454)
KonradStaniec Jan 28, 2025
83af4ad
chore: update cosmos provider to expose public functions (#458)
RafilxTenfen Jan 29, 2025
70b63e6
Merge branch 'main' of github.com:babylonlabs-io/babylon into feat/rm…
RafilxTenfen Jan 31, 2025
58e9e40
fix: lint
RafilxTenfen Jan 31, 2025
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
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
This PR contains a series of PRs on multi-staking support and BTC stakingintegration.
- [#391](https://github.com/babylonlabs-io/babylon/pull/391) Fix e2e `TestBTCRewardsDistribution` flunky
check of rewards
- [#458](https://github.com/babylonlabs-io/babylon/pull/458) Set `CosmosProvider` functions as public
- [#457](https://github.com/babylonlabs-io/babylon/pull/457) Remove staking msg server and update gentx to generate
`MsgWrappedCreateValidator`

### Bug fixes

Expand All @@ -56,8 +59,6 @@ forks starting with already known header
### Improvements

- [#419](https://github.com/babylonlabs-io/babylon/pull/419) Add new modules to swagger config
- [#436](https://github.com/babylonlabs-io/babylon/pull/436) Remove staking msg server to handle at epoch
- [#435](https://github.com/babylonlabs-io/babylon/pull/435) Modify gentx to generate `MsgWrappedCreateValidator`
- [#429](https://github.com/babylonlabs-io/babylon/pull/429) chore: remove cosmos/relayer dependency

### Bug fixes
Expand Down
24 changes: 24 additions & 0 deletions client/babylonclient/chain_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ package babylonclient

import (
"context"
"time"

"github.com/cosmos/cosmos-sdk/client/tx"
sdk "github.com/cosmos/cosmos-sdk/types"
txtypes "github.com/cosmos/cosmos-sdk/types/tx"
)

type BroadcastMode string
Expand Down Expand Up @@ -48,6 +53,25 @@ type ChainProvider interface {
asyncCtx context.Context,
asyncCallbacks []func(*RelayerTxResponse, error),
) error
CalculateGas(ctx context.Context, txf tx.Factory, signingKey string, msgs ...sdk.Msg) (txtypes.SimulateResponse, uint64, error)
BroadcastTx(
ctx context.Context, // context for tx broadcast
tx []byte, // raw tx to be broadcast
asyncCtx context.Context, // context for async wait for block inclusion after successful tx broadcast
asyncTimeout time.Duration, // timeout for waiting for block inclusion
asyncCallbacks []func(*RelayerTxResponse, error), // callback for success/fail of the wait for block inclusion
) error
WaitForTx(
ctx context.Context,
txHash []byte,
waitTimeout time.Duration,
callbacks []func(*RelayerTxResponse, error),
)
WaitForBlockInclusion(
ctx context.Context,
txHash []byte,
waitTimeout time.Duration,
) (*sdk.TxResponse, error)
ChainName() string
ChainId() string
ProviderConfig() ProviderConfig
Expand Down
2 changes: 1 addition & 1 deletion client/babylonclient/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (cc *CosmosProvider) TxServiceBroadcast(ctx context.Context, req *tx.Broadc

wg.Add(1)

if err := cc.broadcastTx(ctx, req.TxBytes, ctx, blockTimeout, []func(*RelayerTxResponse, error){callback}); err != nil {
if err := cc.BroadcastTx(ctx, req.TxBytes, ctx, blockTimeout, []func(*RelayerTxResponse, error){callback}); err != nil {
return nil, err
}

Expand Down
65 changes: 36 additions & 29 deletions client/babylonclient/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ package babylonclient

import (
"context"
sdkerrors "cosmossdk.io/errors"
"cosmossdk.io/store/rootmulti"
"errors"
"fmt"
"math"
"regexp"
"strconv"
"strings"
"sync"
"time"

sdkerrors "cosmossdk.io/errors"
"cosmossdk.io/store/rootmulti"

abci "github.com/cometbft/cometbft/abci/types"
client2 "github.com/cometbft/cometbft/rpc/client"
coretypes "github.com/cometbft/cometbft/rpc/core/types"
Expand All @@ -23,12 +31,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/tx/signing"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"math"
"regexp"
"strconv"
"strings"
"sync"
"time"

"github.com/avast/retry-go/v4"
)
Expand Down Expand Up @@ -99,10 +101,10 @@ func (cc *CosmosProvider) QueryABCI(ctx context.Context, req abci.RequestQuery)
return result.Response, nil
}

// broadcastTx broadcasts a transaction with the given raw bytes and then, in an async goroutine, waits for the tx to be included in the block.
// BroadcastTx broadcasts a transaction with the given raw bytes and then, in an async goroutine, waits for the tx to be included in the block.
// The wait will end after either the asyncTimeout has run out or the asyncCtx exits.
// If there is no error broadcasting, the asyncCallback will be called with success/failure of the wait for block inclusion.
func (cc *CosmosProvider) broadcastTx(
func (cc *CosmosProvider) BroadcastTx(
ctx context.Context, // context for tx broadcast
tx []byte, // raw tx to be broadcast
asyncCtx context.Context, // context for async wait for block inclusion after successful tx broadcast
Expand Down Expand Up @@ -132,20 +134,20 @@ func (cc *CosmosProvider) broadcastTx(

// TODO: maybe we need to check if the node has tx indexing enabled?
// if not, we need to find a new way to block until inclusion in a block
go cc.waitForTx(asyncCtx, res.Hash, asyncTimeout, asyncCallbacks)
go cc.WaitForTx(asyncCtx, res.Hash, asyncTimeout, asyncCallbacks)

return nil
}

// waitForTx waits for a transaction to be included in a block, logs success/fail, then invokes callback.
// WaitForTx waits for a transaction to be included in a block, logs success/fail, then invokes callback.
// This is intended to be called as an async goroutine.
func (cc *CosmosProvider) waitForTx(
func (cc *CosmosProvider) WaitForTx(
ctx context.Context,
txHash []byte,
waitTimeout time.Duration,
callbacks []func(*RelayerTxResponse, error),
) {
res, err := cc.waitForBlockInclusion(ctx, txHash, waitTimeout)
res, err := cc.WaitForBlockInclusion(ctx, txHash, waitTimeout)
if err != nil {
if len(callbacks) > 0 {
for _, cb := range callbacks {
Expand All @@ -162,7 +164,7 @@ func (cc *CosmosProvider) waitForTx(
Codespace: res.Codespace,
Code: res.Code,
Data: res.Data,
Events: parseEventsFromTxResponse(res),
Events: ParseEventsFromTxResponse(res),
}

// NOTE: error is nil, logic should use the returned error to determine if the
Expand Down Expand Up @@ -190,8 +192,8 @@ func (cc *CosmosProvider) waitForTx(
}
}

// waitForBlockInclusion will wait for a transaction to be included in a block, up to waitTimeout or context cancellation.
func (cc *CosmosProvider) waitForBlockInclusion(
// WaitForBlockInclusion will wait for a transaction to be included in a block, up to waitTimeout or context cancellation.
func (cc *CosmosProvider) WaitForBlockInclusion(
ctx context.Context,
txHash []byte,
waitTimeout time.Duration,
Expand Down Expand Up @@ -280,7 +282,7 @@ func (cc *CosmosProvider) sdkError(codeSpace string, code uint32) error {
return nil
}

func parseEventsFromTxResponse(resp *sdk.TxResponse) []RelayerEvent {
func ParseEventsFromTxResponse(resp *sdk.TxResponse) []RelayerEvent {
var events []RelayerEvent

if resp == nil {
Expand Down Expand Up @@ -354,7 +356,7 @@ func (cc *CosmosProvider) SendMessagesToMempool(
sequenceGuard.Mu.Lock()
defer sequenceGuard.Mu.Unlock()

txBytes, sequence, _, err := cc.buildMessages(ctx, msgs, memo, 0, txSignerKey, sequenceGuard)
txBytes, sequence, _, err := cc.BuildMessages(ctx, tx.Factory{}, msgs, memo, 0, txSignerKey, sequenceGuard)
if err != nil {
// Account sequence mismatch errors can happen on the simulated transaction also.
if strings.Contains(err.Error(), legacyerrors.ErrWrongSequence.Error()) {
Expand All @@ -364,7 +366,7 @@ func (cc *CosmosProvider) SendMessagesToMempool(
return err
}

if err := cc.broadcastTx(ctx, txBytes, asyncCtx, defaultBroadcastWaitTimeout, asyncCallbacks); err != nil {
if err := cc.BroadcastTx(ctx, txBytes, asyncCtx, defaultBroadcastWaitTimeout, asyncCallbacks); err != nil {
if strings.Contains(err.Error(), legacyerrors.ErrWrongSequence.Error()) {
cc.handleAccountSequenceMismatchError(sequenceGuard, err)
}
Expand All @@ -373,18 +375,19 @@ func (cc *CosmosProvider) SendMessagesToMempool(
}

// we had a successful tx broadcast with this sequence, so update it to the next
cc.updateNextAccountSequence(sequenceGuard, sequence+1)
cc.UpdateNextAccountSequence(sequenceGuard, sequence+1)
return nil
}

func (cc *CosmosProvider) updateNextAccountSequence(sequenceGuard *WalletState, seq uint64) {
func (cc *CosmosProvider) UpdateNextAccountSequence(sequenceGuard *WalletState, seq uint64) {
if seq > sequenceGuard.NextAccountSequence {
sequenceGuard.NextAccountSequence = seq
}
}

func (cc *CosmosProvider) buildMessages(
func (cc *CosmosProvider) BuildMessages(
ctx context.Context,
txf tx.Factory,
msgs []RelayerMessage,
memo string,
gas uint64,
Expand All @@ -401,7 +404,7 @@ func (cc *CosmosProvider) buildMessages(

cMsgs := CosmosMsgs(msgs...)

txf, err := cc.PrepareFactory(cc.TxFactory(), txSignerKey)
txf, err = cc.PrepareFactory(cc.TxFactoryWithDefaults(txf), txSignerKey)
if err != nil {
return nil, 0, sdk.Coins{}, err
}
Expand All @@ -411,7 +414,7 @@ func (cc *CosmosProvider) buildMessages(
}

sequence = txf.Sequence()
cc.updateNextAccountSequence(sequenceGuard, sequence)
cc.UpdateNextAccountSequence(sequenceGuard, sequence)
if sequence < sequenceGuard.NextAccountSequence {
sequence = sequenceGuard.NextAccountSequence
txf = txf.WithSequence(sequence)
Expand All @@ -421,7 +424,6 @@ func (cc *CosmosProvider) buildMessages(

if gas == 0 {
_, adjusted, err = cc.CalculateGas(ctx, txf, txSignerKey, cMsgs...)

if err != nil {
return nil, 0, sdk.Coins{}, err
}
Expand Down Expand Up @@ -520,9 +522,14 @@ func (cc *CosmosProvider) PrepareFactory(txf tx.Factory, signingKey string) (tx.
return txf, nil
}

// TxFactory instantiates a new tx factory with the appropriate configuration settings for this chain.
func (cc *CosmosProvider) TxFactory() tx.Factory {
return tx.Factory{}.
// NewTxFactory instantiates a new tx factory with the appropriate configuration settings for this chain.
func (cc *CosmosProvider) NewTxFactory() tx.Factory {
return cc.TxFactoryWithDefaults(tx.Factory{})
}

// TxFactoryWithDefaults instantiates a new tx factory with the appropriate configuration settings for this chain.
func (cc *CosmosProvider) TxFactoryWithDefaults(baseTxf tx.Factory) tx.Factory {
return baseTxf.
WithAccountRetriever(cc).
WithChainID(cc.PCfg.ChainID).
WithTxConfig(cc.Cdc.TxConfig).
Expand Down
4 changes: 2 additions & 2 deletions client/client/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package client
import (
"context"
"fmt"
"github.com/babylonlabs-io/babylon/client/babylonclient"
"sync"

signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1"
"cosmossdk.io/errors"
txsigning "cosmossdk.io/x/tx/signing"
"github.com/avast/retry-go/v4"
"github.com/babylonlabs-io/babylon/client/babylonclient"
btcctypes "github.com/babylonlabs-io/babylon/x/btccheckpoint/types"
btclctypes "github.com/babylonlabs-io/babylon/x/btclightclient/types"
abci "github.com/cometbft/cometbft/abci/types"
Expand Down Expand Up @@ -222,7 +222,7 @@ func (c *Client) SendMessageWithSigner(
WithCodec(cc.Cdc.Codec).
WithFromAddress(signerAddr)

txf := cc.TxFactory()
txf := cc.NewTxFactory()
if err := retry.Do(func() error {
if err := txf.AccountRetriever().EnsureExists(cliCtx, signerAddr); err != nil {
return err
Expand Down
Loading