Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
16 changes: 14 additions & 2 deletions harness/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,19 @@ func startRemoteHarness(cmdCtx context.Context, cfg config.Config) error {
return fmt.Errorf("error collecting the finality providers %w", err)
}

paramsResp, err := bbnClient.BTCCheckpointParams()
if err != nil {
return fmt.Errorf("failed to get staking params: %w", err)
}

var stakers []*BTCStaker
for i := 0; i < cfg.TotalStakers; i++ {
stakerSender, err := NewSenderWithBabylonClient(cmdCtx, fmt.Sprintf("staker-%d", i), cfg.BabylonRPC, cfg.BabylonGRPC)
if err != nil {
return fmt.Errorf("failed to create staker sender: %w", err)
}

staker := NewBTCStaker(btcClient.client, stakerSender, fpPks, nil, nil)
staker := NewBTCStaker(btcClient.client, stakerSender, fpPks, &paramsResp.Params, nil, nil)
stakers = append(stakers, staker)
}

Expand All @@ -94,6 +99,8 @@ func startRemoteHarness(cmdCtx context.Context, cfg config.Config) error {
return fmt.Errorf("failed to start stakers: %w", err)
}

<-cmdCtx.Done()

return nil
}

Expand Down Expand Up @@ -159,6 +166,11 @@ func startHarness(cmdCtx context.Context, cfg config.Config) error {
return err
}

paramsResp, err := cpSender.BTCCheckpointParams()
if err != nil {
return fmt.Errorf("failed to get staking params: %w", err)
}

var stakers []*BTCStaker
for i := 0; i < numStakers; i++ {
stakerSender, err := NewSenderWithBabylonClient(ctx, fmt.Sprintf("staker-%d", i), tm.Config.Babylon1.RPCAddr, tm.Config.Babylon1.GRPCAddr)
Expand All @@ -167,7 +179,7 @@ func startHarness(cmdCtx context.Context, cfg config.Config) error {
}

rndFpChunk := fpMgr.getRandomChunk(3)
stakers = append(stakers, NewBTCStaker(tm.TestRpcClient, stakerSender, rndFpChunk, tm.fundingRequests, tm.fundingResponse))
stakers = append(stakers, NewBTCStaker(tm.TestRpcClient, stakerSender, rndFpChunk, &paramsResp.Params, tm.fundingRequests, tm.fundingResponse))
}

// periodically check if we need to fund the staker
Expand Down
13 changes: 8 additions & 5 deletions harness/btcclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,14 @@ func (c *BTCClient) checkBalance() error {
func (c *BTCClient) Setup(cfg config.Config) error {
c.config = c.ConvertToBTCConfig(cfg)
rpcClient, err := rpcclient.New(&rpcclient.ConnConfig{
Host: rpcHostURL(c.config.Endpoint, c.config.WalletName),
User: c.config.Username,
Pass: c.config.Password,
DisableTLS: true,
HTTPPostMode: true,
Host: rpcHostURL(c.config.Endpoint, c.config.WalletName),
Endpoint: c.config.Endpoint,
User: c.config.Username,
Pass: c.config.Password,
DisableTLS: true,
DisableConnectOnNew: true,
DisableAutoReconnect: false,
HTTPPostMode: true,
}, nil)
if err != nil {
return err
Expand Down
5 changes: 4 additions & 1 deletion harness/btcstaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type BTCStaker struct {
client *SenderWithBabylonClient
fpPK *btcec.PublicKey
fpPKChunk []*btcec.PublicKey
btcCkpParams *btckpttypes.Params
fundingRequest chan sdk.AccAddress
fundingResponse chan sdk.AccAddress
}
Expand All @@ -43,13 +44,15 @@ func NewBTCStaker(
btcClient *rpcclient.Client,
client *SenderWithBabylonClient,
finalityProvidersPublicKey []*btcec.PublicKey,
btcCkpParams *btckpttypes.Params,
fundingRequest chan sdk.AccAddress,
fundingResponse chan sdk.AccAddress,
) *BTCStaker {
return &BTCStaker{
btcClient: btcClient,
client: client,
fpPKChunk: finalityProvidersPublicKey,
btcCkpParams: btcCkpParams,
fundingRequest: fundingRequest,
fundingResponse: fundingResponse,
}
Expand Down Expand Up @@ -429,7 +432,7 @@ func (s *BTCStaker) buildAndSendStakingTransaction(
}

// TODO: hardcoded two in tests
inclusionProof := s.waitForTransactionConfirmation(ctx, hash, 2)
inclusionProof := s.waitForTransactionConfirmation(ctx, hash, s.btcCkpParams.BtcConfirmationDepth)

if inclusionProof == nil {
// we are quiting
Expand Down
3 changes: 2 additions & 1 deletion harness/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ func AtomicFundSignSendStakingTx(rpcClient *rpcclient.Client, stakingOutput *wir
feeRate := float64(0.00002)
pos := 1

err := rpcClient.WalletPassphrase("pass", 60)
//Add password in here for remote/dynamically
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you don't plan to fix in this PR, add a TODO

err := rpcClient.WalletPassphrase("pass", 50)
if err != nil {
return nil, nil, err
}
Expand Down