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

Merge main back to dev #62

Merged
merged 4 commits into from
Jul 24, 2024
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
102 changes: 0 additions & 102 deletions .circleci/config.yml

This file was deleted.

20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: ci

on:
pull_request:
branches:
- '**'

jobs:
lint_test:
uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0
with:
run-unit-tests: true
run-integration-tests: true
run-lint: true

docker_pipeline:
uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0
secrets: inherit
with:
publish: false
24 changes: 24 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: docker_publish

on:
push:
branches:
- 'main'
- 'dev'
tags:
- '**'

jobs:
lint_test:
uses: babylonchain/.github/.github/workflows/reusable_go_lint_test.yml@v0.1.0
with:
run-unit-tests: true
run-integration-tests: true
run-lint: true

docker_pipeline:
needs: ["lint_test"]
uses: babylonchain/.github/.github/workflows/reusable_docker_pipeline.yml@v0.1.0
secrets: inherit
with:
publish: true
20 changes: 10 additions & 10 deletions cmd/createStakingTxCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
FlagMagicBytes = "magic-bytes"
FlagTag = "tag"
FlagStakerPk = "staker-pk"
FlagStakingAmount = "staking-amount"
FlagStakingTime = "staking-time"
Expand Down Expand Up @@ -186,17 +186,17 @@ func parseTimeLock(timeBlocks int64) (uint16, error) {
return uint16(timeBlocks), nil
}

func parseMagicBytesFromHex(magicBytesHex string) ([]byte, error) {
magicBytes, err := hex.DecodeString(magicBytesHex)
func parseTagFromHex(tagHex string) ([]byte, error) {
tag, err := hex.DecodeString(tagHex)
if err != nil {
return nil, err
}

if len(magicBytes) != btcstaking.MagicBytesLen {
return nil, fmt.Errorf("magic bytes should be of length %d", btcstaking.MagicBytesLen)
if len(tag) != btcstaking.TagLen {
return nil, fmt.Errorf("tag should be of length %d", btcstaking.TagLen)
}

return magicBytes, nil
return tag, nil
}

func parsePosNum(num int64) (uint32, error) {
Expand All @@ -216,8 +216,8 @@ type CreateStakingTxResp struct {
}

func init() {
createStakingTxCmd.Flags().String(FlagMagicBytes, "", "magic bytes")
_ = createStakingTxCmd.MarkFlagRequired(FlagMagicBytes)
createStakingTxCmd.Flags().String(FlagTag, "", "tag")
_ = createStakingTxCmd.MarkFlagRequired(FlagTag)
createStakingTxCmd.Flags().String(FlagStakerPk, "", "staker pk")
_ = createStakingTxCmd.MarkFlagRequired(FlagStakerPk)
createStakingTxCmd.Flags().String(FlagFinalityProviderPk, "", "finality provider pk")
Expand Down Expand Up @@ -246,7 +246,7 @@ var createStakingTxCmd = &cobra.Command{
return err
}

magicBytes, err := parseMagicBytesFromHex(mustGetStringFlag(cmd, FlagMagicBytes))
tag, err := parseTagFromHex(mustGetStringFlag(cmd, FlagTag))

if err != nil {
return err
Expand Down Expand Up @@ -289,7 +289,7 @@ var createStakingTxCmd = &cobra.Command{
}

_, tx, err := btcstaking.BuildV0IdentifiableStakingOutputsAndTx(
magicBytes,
tag,
stakerPk,
finalityProviderPk,
covenantCommitteePks,
Expand Down
13 changes: 7 additions & 6 deletions cmd/createUnbondingTxCmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ import (
"fmt"

"github.com/babylonchain/babylon/btcstaking"
"github.com/babylonchain/cli-tools/internal/btcclient"
"github.com/babylonchain/cli-tools/internal/config"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/wire"
"github.com/decred/dcrd/dcrec/secp256k1/v4"
"github.com/spf13/cobra"

"github.com/babylonchain/cli-tools/internal/btcclient"
"github.com/babylonchain/cli-tools/internal/config"
)

var (
Expand All @@ -31,8 +32,8 @@ func init() {
// parsing it wil fail
createUnbondingTxCmd.Flags().String(FlagStakingTxHex, "", "funded staking tx hex")
_ = createUnbondingTxCmd.MarkFlagRequired(FlagStakingTxHex)
createUnbondingTxCmd.Flags().String(FlagMagicBytes, "", "magic bytes")
_ = createUnbondingTxCmd.MarkFlagRequired(FlagMagicBytes)
createUnbondingTxCmd.Flags().String(FlagTag, "", "tag")
_ = createUnbondingTxCmd.MarkFlagRequired(FlagTag)
createUnbondingTxCmd.Flags().Int64(FlagUnbondingTime, 0, "unbonding time")
_ = createUnbondingTxCmd.MarkFlagRequired(FlagUnbondingTime)
createUnbondingTxCmd.Flags().Int64(FlagUnbondingTxFee, 0, "unbonding fee")
Expand Down Expand Up @@ -142,7 +143,7 @@ var createUnbondingTxCmd = &cobra.Command{
return err
}

magicBytes, err := parseMagicBytesFromHex(mustGetStringFlag(cmd, FlagMagicBytes))
tag, err := parseTagFromHex(mustGetStringFlag(cmd, FlagTag))

if err != nil {
return err
Expand Down Expand Up @@ -180,7 +181,7 @@ var createUnbondingTxCmd = &cobra.Command{

parsedStakingTx, err := btcstaking.ParseV0StakingTx(
stakingTx,
magicBytes,
tag,
covenantCommitteePks,
covenantQuorum,
btcParams,
Expand Down
13 changes: 7 additions & 6 deletions cmd/createWithdrawTxCmg.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"fmt"

"github.com/babylonchain/babylon/btcstaking"
"github.com/babylonchain/cli-tools/internal/btcclient"
"github.com/babylonchain/cli-tools/internal/config"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/btcutil"
"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
"github.com/spf13/cobra"

"github.com/babylonchain/cli-tools/internal/btcclient"
"github.com/babylonchain/cli-tools/internal/config"
)

var (
Expand All @@ -24,8 +25,8 @@ func init() {
// parsing it wil fail
createWithdrawCmd.Flags().String(FlagStakingTxHex, "", "funded staking tx hex")
_ = createWithdrawCmd.MarkFlagRequired(FlagStakingTxHex)
createWithdrawCmd.Flags().String(FlagMagicBytes, "", "magic bytes")
_ = createWithdrawCmd.MarkFlagRequired(FlagMagicBytes)
createWithdrawCmd.Flags().String(FlagTag, "", "tag")
_ = createWithdrawCmd.MarkFlagRequired(FlagTag)
createWithdrawCmd.Flags().Int64(FlagWithdrawTxFee, 0, "withdraw fee")
_ = createWithdrawCmd.MarkFlagRequired(FlagWithdrawTxFee)
createWithdrawCmd.Flags().StringSlice(FlagCovenantCommitteePks, nil, "covenant committee pks")
Expand Down Expand Up @@ -74,7 +75,7 @@ var createWithdrawCmd = &cobra.Command{
return err
}

magicBytes, err := parseMagicBytesFromHex(mustGetStringFlag(cmd, FlagMagicBytes))
tag, err := parseTagFromHex(mustGetStringFlag(cmd, FlagTag))

if err != nil {
return err
Expand Down Expand Up @@ -118,7 +119,7 @@ var createWithdrawCmd = &cobra.Command{

parsedStakingTx, err := btcstaking.ParseV0StakingTx(
stakingTx,
magicBytes,
tag,
covenantCommitteePks,
covenantQuorum,
btcParams,
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ go 1.22.3
toolchain go1.22.4

require (
github.com/babylonchain/babylon v0.9.0-rc.1
github.com/babylonchain/babylon v0.9.0-rc.3
github.com/babylonchain/covenant-signer v0.2.6
github.com/babylonchain/networks/parameters v0.2.1
github.com/btcsuite/btcd v0.24.0
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
github.com/btcsuite/btcd/btcutil v1.1.5
github.com/btcsuite/btcd/chaincfg/chainhash v1.1.0
Expand Down Expand Up @@ -262,6 +262,7 @@ require (
github.com/sasha-s/go-deadlock v0.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/supranational/blst v0.3.11 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20220721030215-126854af5e6d // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,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/babylonchain/babylon v0.9.0-rc.1 h1:mZYKQVHVKFUA2xaEAzJloB1kyePHvZECJPgm3p9TYas=
github.com/babylonchain/babylon v0.9.0-rc.1/go.mod h1:YFALTW+Kp/b5jSDoA7Z70RggJjAedlmQTrpdeU8c3hY=
github.com/babylonchain/babylon v0.9.0-rc.3 h1:Coaf37uqVvNBMpR0VR8nRcJsCx9FpAU4psRc5BGK1K8=
github.com/babylonchain/babylon v0.9.0-rc.3/go.mod h1:QTjpnEAEReQofIpZikCQXUZxSkdK0TrWAUbgxOSF9yA=
github.com/babylonchain/covenant-signer v0.2.6 h1:Dh72ounwl4WsPVd99IBY7uWlSv7zOXwWeMLOfkEx4+U=
github.com/babylonchain/covenant-signer v0.2.6/go.mod h1:67vSxNxAi/tfDp0WhVK2Sutj/f/ml1lJERY3asR3VuU=
github.com/babylonchain/networks/parameters v0.2.1 h1:OKHiCnwL/UdVN17cMwCrHz/bAjO/USauLiPyNlnVl6E=
Expand All @@ -304,8 +304,8 @@ github.com/btcsuite/btcd v0.22.0-beta.0.20220207191057-4dc4ff7963b4/go.mod h1:7a
github.com/btcsuite/btcd v0.23.1/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
github.com/btcsuite/btcd v0.23.3/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
github.com/btcsuite/btcd v0.23.5-0.20231215221805-96c9fd8078fd/go.mod h1:nm3Bko6zh6bWP60UxwoT5LzdGJsQJaPo6HjduXq9p6A=
github.com/btcsuite/btcd v0.24.0 h1:gL3uHE/IaFj6fcZSu03SvqPMSx7s/dPzfpG/atRwWdo=
github.com/btcsuite/btcd v0.24.0/go.mod h1:K4IDc1593s8jKXIF7yS7yCTSxrknB9z0STzc2j6XgE4=
github.com/btcsuite/btcd v0.24.2 h1:aLmxPguqxza+4ag8R1I2nnJjSu2iFn/kqtHTIImswcY=
github.com/btcsuite/btcd v0.24.2/go.mod h1:5C8ChTkl5ejr3WHj8tkQSCmydiMEPB0ZhQhehpq7Dgg=
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
Expand Down
2 changes: 1 addition & 1 deletion internal/services/expected_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type BtcSender interface {
type SystemParams struct {
CovenantPublicKeys []*btcec.PublicKey
CovenantQuorum uint32
MagicBytes []byte
Tag []byte
}

type ParamsRetriever interface {
Expand Down
2 changes: 1 addition & 1 deletion internal/services/global_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ func (g *VersionedParamsRetriever) ParamsByHeight(_ context.Context, height uint
return &SystemParams{
CovenantPublicKeys: versionedParams.CovenantPks,
CovenantQuorum: versionedParams.CovenantQuorum,
MagicBytes: versionedParams.Tag,
Tag: versionedParams.Tag,
}, nil
}
Loading