diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f127163..8383b120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Improvements -* [#517](https://github.com/babylonlabs-io/finality-provider/pull/518) feat: rollup BSN finality provider setup * [#493](https://github.com/babylonlabs-io/finality-provider/pull/493) chore: key migration for test keyring * [#501](https://github.com/babylonlabs-io/finality-provider/pull/501) chore: signing context * [#500](https://github.com/babylonlabs-io/finality-provider/pull/500) feat: fpd abstract poller implementation @@ -52,6 +51,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * [515](https://github.com/babylonlabs-io/finality-provider/pull/515) chore: abstract randomness committer * [#522](https://github.com/babylonlabs-io/finality-provider/pull/522) cli: refactor CLIs and generalise for rollup FPs * [516](https://github.com/babylonlabs-io/finality-provider/pull/516) chore: abstract bootstrap +* [#517](https://github.com/babylonlabs-io/finality-provider/pull/518) feat: rollup BSN finality provider setup +* [#526](https://github.com/babylonlabs-io/finality-provider/pull/526) rollup: remove dependency to finality gadget ## v1.1.0-rc.1 diff --git a/bsn/rollup-finality-provider/clientcontroller/consumer.go b/bsn/rollup-finality-provider/clientcontroller/consumer.go index b3929eac..00844ab4 100644 --- a/bsn/rollup-finality-provider/clientcontroller/consumer.go +++ b/bsn/rollup-finality-provider/clientcontroller/consumer.go @@ -5,7 +5,6 @@ import ( "encoding/hex" "encoding/json" "fmt" - "math" "math/big" sdkErr "cosmossdk.io/errors" @@ -31,10 +30,6 @@ import ( "go.uber.org/zap" ) -const ( - BabylonChainName = "Babylon" -) - var _ api.ConsumerController = &RollupBSNController{} // nolint:revive // Ignore stutter warning - full name provides clarity @@ -98,8 +93,9 @@ func (cc *RollupBSNController) ReliablySendMsg(ctx context.Context, msg sdk.Msg, return cc.reliablySendMsgs(ctx, []sdk.Msg{msg}, expectedErrs, unrecoverableErrs) } -// QueryContractConfig queries the finality contract for its config -func (cc *RollupBSNController) QueryContractConfig(ctx context.Context) (*Config, error) { +// queryContractConfig queries the finality contract for its config +// nolint:unused +func (cc *RollupBSNController) queryContractConfig(ctx context.Context) (*Config, error) { query := QueryMsg{ Config: &Config{}, } @@ -207,7 +203,7 @@ func (cc *RollupBSNController) SubmitBatchFinalitySigs( FpPubkeyHex: fpPkHex, Height: block.GetHeight(), PubRand: bbntypes.NewSchnorrPubRandFromFieldVal(req.PubRandList[i]).MustMarshal(), - Proof: ConvertProof(cmtProof), + Proof: convertProof(cmtProof), BlockHash: block.Hash, Signature: bbntypes.NewSchnorrEOTSSigFromModNScalar(req.Sigs[i]).MustMarshal(), }, @@ -399,7 +395,8 @@ func (cc *RollupBSNController) QueryBlock(ctx context.Context, height uint64) (t // Note: this is specific to the RollupBSNController and only used for testing // QueryBlock returns the Ethereum block from a RPC call -func (cc *RollupBSNController) QueryEthBlock(ctx context.Context, height uint64) (*ethtypes.Header, error) { +// nolint:unused +func (cc *RollupBSNController) queryEthBlock(ctx context.Context, height uint64) (*ethtypes.Header, error) { return cc.ethClient.HeaderByNumber(ctx, new(big.Int).SetUint64(height)) } @@ -497,7 +494,7 @@ func (cc *RollupBSNController) UnjailFinalityProvider(_ context.Context, _ *btce return nil, nil } -func ConvertProof(cmtProof cmtcrypto.Proof) Proof { +func convertProof(cmtProof cmtcrypto.Proof) Proof { return Proof{ Total: uint64(cmtProof.Total), // #nosec G115 Index: uint64(cmtProof.Index), // #nosec G115 @@ -506,62 +503,6 @@ func ConvertProof(cmtProof cmtcrypto.Proof) Proof { } } -// GetBlockNumberByTimestamp returns the L2 block number for the given BTC staking activation timestamp. -// It uses a binary search to find the block number. -func (cc *RollupBSNController) GetBlockNumberByTimestamp(ctx context.Context, targetTimestamp uint64) (uint64, error) { - // Check if the target timestamp is after the latest block - latestBlock, err := cc.ethClient.HeaderByNumber(ctx, nil) - if err != nil { - return math.MaxUint64, err - } - if targetTimestamp > latestBlock.Time { - return math.MaxUint64, fmt.Errorf("target timestamp %d is after the latest block timestamp %d", targetTimestamp, latestBlock.Time) - } - - // Check if the target timestamp is before the first block - firstBlock, err := cc.ethClient.HeaderByNumber(ctx, big.NewInt(1)) - if err != nil { - return math.MaxUint64, err - } - - // let's say block 0 is at t0 and block 1 at t1 - // if t0 < targetTimestamp < t1, the activated height should be block 1 - if targetTimestamp < firstBlock.Time { - return uint64(1), nil - } - - // binary search between block 1 and the latest block - // start from block 1, b/c some L2s such as OP mainnet, block 0 is genesis block with timestamp 0 - lowerBound := uint64(1) - upperBound := latestBlock.Number.Uint64() - - for lowerBound <= upperBound { - midBlockNumber := (lowerBound + upperBound) / 2 - block, err := cc.ethClient.HeaderByNumber(ctx, big.NewInt(int64(midBlockNumber))) // #nosec G115 - if err != nil { - return math.MaxUint64, err - } - - switch { - case block.Time < targetTimestamp: - lowerBound = midBlockNumber + 1 - case block.Time > targetTimestamp: - upperBound = midBlockNumber - 1 - default: - return midBlockNumber, nil - } - } - - return lowerBound, nil -} - -// QueryFinalityProviderSlashedOrJailed - returns if the fp has been slashed, jailed, err -// nolint:revive // Ignore stutter warning - full name provides clarity -func (cc *RollupBSNController) QueryFinalityProviderSlashedOrJailed(fpPk *btcec.PublicKey) (bool, bool, error) { - // TODO: implement slashed or jailed feature in rollup BSN - return false, false, nil -} - func (cc *RollupBSNController) Close() error { cc.ethClient.Close() diff --git a/bsn/rollup-finality-provider/config/config.go b/bsn/rollup-finality-provider/config/config.go index e2196569..df8e6da3 100644 --- a/bsn/rollup-finality-provider/config/config.go +++ b/bsn/rollup-finality-provider/config/config.go @@ -18,9 +18,8 @@ const ( ) type RollupFPConfig struct { - RollupNodeRPCAddress string `long:"rollup-node-rpc-address" description:"the rpc address of the rollup node to connect to"` - BabylonFinalityGadgetRpc string `long:"babylon-finality-gadget-rpc" description:"the rpc address of rollup finality gadget"` //nolint:stylecheck,revive - FinalityContractAddress string `long:"finality-contract-address" description:"the contract address of the rollup finality contract"` + RollupNodeRPCAddress string `long:"rollup-node-rpc-address" description:"the rpc address of the rollup node to connect to"` + FinalityContractAddress string `long:"finality-contract-address" description:"the contract address of the rollup finality contract"` // Below configurations are needed for the Babylon client Common *fpcfg.Config diff --git a/bsn/rollup-finality-provider/e2e/op_test_manager.go b/bsn/rollup-finality-provider/e2e/op_test_manager.go index 4866f372..87df685f 100644 --- a/bsn/rollup-finality-provider/e2e/op_test_manager.go +++ b/bsn/rollup-finality-provider/e2e/op_test_manager.go @@ -303,9 +303,7 @@ func createRollupFpConfig( FinalityContractAddress: "", // it must be a dialable RPC address checked by NewRollupBSNController RollupNodeRPCAddress: "https://optimism-sepolia.drpc.org", - // the value does not matter for the test - BabylonFinalityGadgetRpc: "127.0.0.1:50051", - Common: cfg, + Common: cfg, } return opConsumerCfg diff --git a/go.mod b/go.mod index 906d9c9f..0aad6214 100644 --- a/go.mod +++ b/go.mod @@ -9,7 +9,6 @@ require ( cosmossdk.io/math v1.5.3 github.com/avast/retry-go/v4 v4.5.1 github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20250710070516-a8ad676746c1 - github.com/babylonlabs-io/finality-gadget v0.1.1 github.com/btcsuite/btcd v0.24.2 github.com/btcsuite/btcd/btcec/v2 v2.3.4 github.com/btcsuite/btcd/btcutil v1.1.6 diff --git a/go.sum b/go.sum index ab8c85f8..06533fc9 100644 --- a/go.sum +++ b/go.sum @@ -739,8 +739,6 @@ github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20250407051200-a5d652116d6d h1:9z github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20250407051200-a5d652116d6d/go.mod h1:ks4/p72aNJTIN8+CnCFxNX0HqfgHdClEwU4LxAxryJQ= github.com/babylonlabs-io/babylon/v3 v3.0.0-snapshot.250711 h1:l95QWwd3hGek0LYiYGp+8I8ljADXApRbshugjMg+1Oo= github.com/babylonlabs-io/babylon/v3 v3.0.0-snapshot.250711/go.mod h1:/X1bVC4WUKDBxRTazXvZd/6WINc2tqXAtZOBJknM8OA= -github.com/babylonlabs-io/finality-gadget v0.1.1 h1:izW+sxtrsVPC9FlGx0wzWTJqRk+buEw9zfV7nXKQmWA= -github.com/babylonlabs-io/finality-gadget v0.1.1/go.mod h1:+BICJA7mUJpfYOSYds1G5w6nLO0gKVe9XwdmpIUiXmk= github.com/babylonlabs-io/tokenfactory v0.50.6-wasmvm2 h1:7wtBLjwncBsYgc+LlW4eir/bGcycrhpbz7PkUVADzBc= github.com/babylonlabs-io/tokenfactory v0.50.6-wasmvm2/go.mod h1:L8XfncoH1M6fOrzqfRVQZePqo54ZlTDdatUpEr0Iz/E= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=