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

try rebase #64

Merged
merged 17 commits into from
Sep 25, 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
45 changes: 44 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,52 @@ jobs:
secrets: inherit
with:
run-unit-tests: true
run-integration-tests: true
run-lint: true

e2e_babylon:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e Babylon tests
run: make test-e2e-babylon

e2e_wasmd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e Wasmd tests
run: make test-e2e-wasmd

e2e_bcd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e BCD tests
run: make test-e2e-bcd

e2e_op:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e OP tests
run: make test-e2e-op

docker_pipeline:
uses: babylonlabs-io/.github/.github/workflows/[email protected]
secrets: inherit
Expand Down
46 changes: 44 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- 'main'
- 'dev'
tags:
- '*'

Expand All @@ -13,9 +12,52 @@ jobs:
uses: babylonlabs-io/.github/.github/workflows/[email protected]
with:
run-unit-tests: true
run-integration-tests: true
run-lint: true

e2e_babylon:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e Babylon tests
run: make test-e2e-babylon

e2e_wasmd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e Wasmd tests
run: make test-e2e-wasmd

e2e_bcd:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e BCD tests
run: make test-e2e-bcd

e2e_op:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22'
- name: Run e2e OP tests
run: make test-e2e-op

docker_pipeline:
needs: ["lint_test"]
uses: babylonlabs-io/.github/.github/workflows/[email protected]
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributing

Finality-provider repository follows the same contributing rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/CONTRIBUTING.md)
repository.
8 changes: 2 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.21.4-alpine as builder
FROM golang:1.22.7-alpine as builder

Check warning on line 1 in Dockerfile

View workflow job for this annotation

GitHub Actions / docker_pipeline / docker_build

The 'as' keyword should match the case of the 'from' keyword

FromAsCasing: 'as' and 'FROM' keywords' casing do not match More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

# Version to build. Default is the Git HEAD.
ARG VERSION="HEAD"
Expand All @@ -12,15 +12,11 @@
libzmq-static libsodium-static gcc


RUN mkdir -p /root/.ssh && ssh-keyscan github.com >> /root/.ssh/known_hosts
RUN git config --global url."[email protected]:".insteadOf "https://github.com/"
ENV GOPRIVATE=github.com/babylonlabs-io/*

# Build
WORKDIR /go/src/github.com/babylonlabs-io/finality-provider
# Cache dependencies
COPY go.mod go.sum /go/src/github.com/babylonlabs-io/finality-provider/
RUN --mount=type=secret,id=sshKey,target=/root/.ssh/id_rsa go mod download
RUN go mod download
# Copy the rest of the files
COPY ./ /go/src/github.com/babylonlabs-io/finality-provider/

Expand Down
5 changes: 5 additions & 0 deletions RELEASE_PROCESS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release Process

Finality-provider repository follows the same release process rules as
[Babylon node](https://github.com/babylonlabs-io/babylon/blob/main/RELEASE_PROCESS.md)
repository.
4 changes: 2 additions & 2 deletions clientcontroller/api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ type ClientController interface {

// Note: the following queries are only for PoC

// QueryFinalityProviderSlashed queries if the finality provider is slashed
// QueryFinalityProviderSlashedOrJailed queries if the finality provider is slashed or slashed
// Note: if the FP wants to get the information from the consumer chain directly, they should add this interface
// function in ConsumerController. (https://github.com/babylonchain/finality-provider/pull/335#discussion_r1606175344)
QueryFinalityProviderSlashed(fpPk *btcec.PublicKey) (bool, error)
QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error)

Close() error
}
Expand Down
42 changes: 25 additions & 17 deletions clientcontroller/babylon/babylon.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ func NewBabylonController(

bbnConfig := fpcfg.BBNConfigToBabylonConfig(cfg)

if err := bbnConfig.Validate(); err != nil {
return nil, fmt.Errorf("invalid config for Babylon client: %w", err)
}

bc, err := bbnclient.New(
&bbnConfig,
logger,
Expand All @@ -59,6 +55,12 @@ func NewBabylonController(
return nil, fmt.Errorf("failed to create Babylon client: %w", err)
}

// makes sure that the key in config really exists and it is a valid bech 32 addr
// to allow using mustGetTxSigner
if _, err := bc.GetAddr(); err != nil {
return nil, err
}

return &BabylonController{
bc,
cfg,
Expand Down Expand Up @@ -142,16 +144,14 @@ func (bc *BabylonController) RegisterFinalityProvider(
return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) QueryFinalityProviderSlashed(fpPk *btcec.PublicKey) (bool, error) {
func (bc *BabylonController) QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (slashed bool, jailed bool, err error) {
fpPubKey := bbntypes.NewBIP340PubKeyFromBTCPK(fpPk)
res, err := bc.bbnClient.QueryClient.FinalityProvider(fpPubKey.MarshalHex())
if err != nil {
return false, fmt.Errorf("failed to query the finality provider %s: %v", fpPubKey.MarshalHex(), err)
return false, false, fmt.Errorf("failed to query the finality provider %s: %v", fpPubKey.MarshalHex(), err)
}

slashed := res.FinalityProvider.SlashedBtcHeight > 0

return slashed, nil
return res.FinalityProvider.SlashedBtcHeight > 0, res.FinalityProvider.Jailed, nil
}

// QueryFinalityProviderHasPower queries whether the finality provider has voting power at a given height
Expand All @@ -161,7 +161,7 @@ func (bc *BabylonController) QueryFinalityProviderHasPower(fpPk *btcec.PublicKey
blockHeight,
)
if err != nil {
return false, fmt.Errorf("failed to query BTC delegations: %w", err)
return false, fmt.Errorf("failed to query Finality Voting Power at Height %d: %w", blockHeight, err)
}

return res.VotingPower > 0, nil
Expand Down Expand Up @@ -332,7 +332,15 @@ func (bc *BabylonController) QueryBtcLightClientTip() (*btclctypes.BTCHeaderInfo
return res.Header, nil
}

// TODO: this method only used in test. this should be refactored out to test files
func (bc *BabylonController) QueryCurrentEpoch() (uint64, error) {
res, err := bc.bbnClient.QueryClient.CurrentEpoch()
if err != nil {
return 0, fmt.Errorf("failed to query BTC tip: %v", err)
}

return res.CurrentEpoch, nil
}

func (bc *BabylonController) QueryVotesAtHeight(height uint64) ([]bbntypes.BIP340PubKey, error) {
res, err := bc.bbnClient.QueryClient.VotesAtHeight(height)
if err != nil {
Expand Down Expand Up @@ -387,20 +395,16 @@ func (bc *BabylonController) QueryStakingParams() (*types.StakingParams, error)
}
covenantPks = append(covenantPks, covPk)
}
slashingAddress, err := btcutil.DecodeAddress(stakingParamRes.Params.SlashingAddress, bc.btcParams)
if err != nil {
return nil, err
}

return &types.StakingParams{
ComfirmationTimeBlocks: ckptParamRes.Params.BtcConfirmationDepth,
FinalizationTimeoutBlocks: ckptParamRes.Params.CheckpointFinalizationTimeout,
MinSlashingTxFeeSat: btcutil.Amount(stakingParamRes.Params.MinSlashingTxFeeSat),
CovenantPks: covenantPks,
SlashingAddress: slashingAddress,
SlashingPkScript: stakingParamRes.Params.SlashingPkScript,
CovenantQuorum: stakingParamRes.Params.CovenantQuorum,
SlashingRate: stakingParamRes.Params.SlashingRate,
MinUnbondingTime: stakingParamRes.Params.MinUnbondingTime,
MinUnbondingTime: stakingParamRes.Params.MinUnbondingTimeBlocks,
}, nil
}

Expand Down Expand Up @@ -460,3 +464,7 @@ func (bc *BabylonController) RegisterConsumerChain(id, name, description string)

return &types.TxResponse{TxHash: res.TxHash}, nil
}

func (bc *BabylonController) GetBBNClient() *bbnclient.Client {
return bc.bbnClient
}
1 change: 1 addition & 0 deletions clientcontroller/retry_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var unrecoverableErrors = []*sdkErr.Error{
finalitytypes.ErrPubRandNotFound,
finalitytypes.ErrTooFewPubRand,
btcstakingtypes.ErrFpAlreadySlashed,
btcstakingtypes.ErrFpAlreadyJailed,
}

// IsUnrecoverable returns true when the error is in the unrecoverableErrors list
Expand Down
2 changes: 1 addition & 1 deletion eotsmanager/proto/eotsmanager.pb.go

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

Loading
Loading