Skip to content

Commit

Permalink
try fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianElvis committed Aug 13, 2024
1 parent f656358 commit b099d9a
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 41 deletions.
4 changes: 0 additions & 4 deletions clientcontroller/api/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ import (
"github.com/babylonlabs-io/finality-provider/types"
)

const (
babylonConsumerChainName = "babylon"
)

type ClientController interface {
// RegisterFinalityProvider registers a finality provider to the consumer chain
// it returns tx hash and error. The address of the finality provider will be
Expand Down
16 changes: 5 additions & 11 deletions clientcontroller/cosmwasm/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"sort"
"strings"

sdkErr "cosmossdk.io/errors"
wasmdparams "github.com/CosmWasm/wasmd/app/params"
Expand Down Expand Up @@ -298,29 +299,22 @@ func (wc *CosmwasmConsumerController) QueryLastPublicRandCommit(fpPk *btcec.Publ
return nil, fmt.Errorf("failed to query smart contract state: %w", err)
}

if len(dataFromContract.Data) == 0 {
if dataFromContract == nil || dataFromContract.Data == nil || len(dataFromContract.Data.Bytes()) == 0 || strings.Contains(string(dataFromContract.Data), "null") {
// expected when there is no PR commit at all
return nil, nil
}

// Define a response struct
var commitResp PubRandCommitResponse
err = json.Unmarshal(dataFromContract.Data, &commitResp)
var commit fptypes.PubRandCommit
err = json.Unmarshal(dataFromContract.Data.Bytes(), &commit)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal response: %w", err)
}

commit := &fptypes.PubRandCommit{
StartHeight: commitResp.StartHeight,
NumPubRand: commitResp.NumPubRand,
Commitment: commitResp.Commitment,
}

if err := commit.Validate(); err != nil {
return nil, err
}

return commit, nil
return &commit, nil
}

func (wc *CosmwasmConsumerController) QueryIsBlockFinalized(height uint64) (bool, error) {
Expand Down
8 changes: 1 addition & 7 deletions clientcontroller/cosmwasm/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,5 @@ type QueryMsgLastPubRandCommit struct {
}

type LastPubRandCommitQuery struct {
BtcPkHex string `json:"btc_pk_hex"`
Limit *uint64 `json:"limit,omitempty"`
}
type PubRandCommitResponse struct {
StartHeight uint64 `json:"start_height"`
NumPubRand uint64 `json:"num_pub_rand"`
Commitment []byte `json:"commitment"`
BtcPkHex string `json:"btc_pk_hex"`
}
4 changes: 2 additions & 2 deletions clientcontroller/opstackl2/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
)

const (
BabylonChainName = "Babylon"
BABYLON_CHAIN_NAME = "Babylon"
)

var _ api.ConsumerController = &OPStackL2ConsumerController{}
Expand Down Expand Up @@ -87,7 +87,7 @@ func NewCwClient(cwConfig *cwconfig.CosmwasmConfig, logger *zap.Logger) (*cwclie

cwClient, err := cwclient.New(
cwConfig,
BabylonChainName,
BABYLON_CHAIN_NAME,
cwEncodingCfg,
logger,
)
Expand Down
2 changes: 1 addition & 1 deletion finality-provider/service/fp_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -1020,7 +1020,7 @@ func (fp *FinalityProviderInstance) lastCommittedPublicRandWithRetry() (*types.P
return nil
}, RtyAtt, RtyDel, RtyErr, retry.OnRetry(func(n uint, err error) {
fp.logger.Debug(
"failed to query babylon for the last committed public randomness",
"failed to query the last committed public randomness",
zap.Uint("attempt", n+1),
zap.Uint("max_attempts", RtyAttNum),
zap.Error(err),
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/CosmWasm/wasmd v0.52.0
github.com/avast/retry-go/v4 v4.5.1
github.com/babylonlabs-io/babylon v0.9.0
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338
github.com/babylonlabs-io/finality-gadget v0.1.1-0.20240813005904-2fa76c30cb74
github.com/btcsuite/btcd v0.24.2
github.com/btcsuite/btcd/btcec/v2 v2.3.2
Expand Down Expand Up @@ -46,7 +46,7 @@ require (

require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b // indirect
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338 // indirect
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd // indirect
github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792 // indirect
github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd // indirect
Expand Down
12 changes: 4 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,10 @@ github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/babylonlabs-io/babylon-private v0.9.0-rc.3.0.20240801001431-74a24c962ce2 h1:sFsAJkrYe1eIkKzWTn4sj7G6QrPQ3IK33/UlOVgeA5M=
github.com/babylonlabs-io/babylon-private v0.9.0-rc.3.0.20240801001431-74a24c962ce2/go.mod h1:pyFZgF85gUhfiCJKbYjnxo5+9prDkti48tW4FDEu9js=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b h1:RctaFr4Svn/gbTa6FkPi78Jkm81J/NFFtp2V2ogMyl0=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b/go.mod h1:8t6U0E4bCQlRQQSKIXNTpTOjACVihJd5wdMLxL55jFE=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b h1:DeP6CzLozsd1MFSOf/Xo3FoBqROW6YZ8fq5ayR3KPwM=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b/go.mod h1:fCwb573m5JgCpuAZ+MK3Kx4WIV+q60TaPRu/m8fCcr0=
github.com/babylonlabs-io/finality-gadget v0.0.0-20240810191700-9ddea258bce5 h1:PgJJS7ae2fFJKRRmb5epXabwuVl0SYIDIRz4n+NUNG0=
github.com/babylonlabs-io/finality-gadget v0.0.0-20240810191700-9ddea258bce5/go.mod h1:+BICJA7mUJpfYOSYds1G5w6nLO0gKVe9XwdmpIUiXmk=
github.com/babylonlabs-io/finality-gadget v0.1.0 h1:7Hytq+StGQgFPBbqQ/8ONlXyS21YTS+IEha5zFLAAH8=
github.com/babylonlabs-io/finality-gadget v0.1.0/go.mod h1:aVEXVcozo62wRXJM639Dnp4u69u5Wjb3rUr1our7YTU=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338 h1:a45+o47CqEksgeyX1IBbWoxPojIVLOIARxH9uBsHe70=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338/go.mod h1:QqEn1sL4RPG7DJ94XFYvuvEELml64s5XwPQpTayXJss=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338 h1:48YwlQpQELyuVb7D/r2NMh7Op8K9WYMcnKUpeH3a+5c=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338/go.mod h1:WJlZy0RYCtyBFeO1mr0Tlo02csrlCAQgzmp4+NVX14g=
github.com/babylonlabs-io/finality-gadget v0.1.1-0.20240813005904-2fa76c30cb74 h1:PrkYtnJyYs4eTEbR5yaEJk6yV6UPuAWiDZQBAMEsvL8=
github.com/babylonlabs-io/finality-gadget v0.1.1-0.20240813005904-2fa76c30cb74/go.mod h1:+BICJA7mUJpfYOSYds1G5w6nLO0gKVe9XwdmpIUiXmk=
github.com/babylonlabs-io/optimism v1.8.1-0.20240808190817-3279057d5250 h1:3FNsa55pbil/Ff7NICtaZzcdLwRs9HsCXJNmW7hDzPs=
Expand Down
Binary file modified itest/bytecode/babylon_contract.wasm
Binary file not shown.
Binary file modified itest/bytecode/btc_staking.wasm
Binary file not shown.
4 changes: 2 additions & 2 deletions tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.4
require (
github.com/CosmWasm/wasmd v0.52.0
github.com/babylonlabs-io/babylon v0.9.0
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338
)

require (
Expand Down Expand Up @@ -39,7 +39,7 @@ require (
github.com/DataDog/zstd v1.5.5 // indirect
github.com/aead/siphash v1.0.1 // indirect
github.com/aws/aws-sdk-go v1.44.312 // indirect
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b // indirect
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect
Expand Down
8 changes: 4 additions & 4 deletions tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,10 @@ github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/babylonlabs-io/babylon-private v0.9.0-rc.3.0.20240801001431-74a24c962ce2 h1:sFsAJkrYe1eIkKzWTn4sj7G6QrPQ3IK33/UlOVgeA5M=
github.com/babylonlabs-io/babylon-private v0.9.0-rc.3.0.20240801001431-74a24c962ce2/go.mod h1:pyFZgF85gUhfiCJKbYjnxo5+9prDkti48tW4FDEu9js=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b h1:RctaFr4Svn/gbTa6FkPi78Jkm81J/NFFtp2V2ogMyl0=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240802071655-9fd2ddd5158b/go.mod h1:8t6U0E4bCQlRQQSKIXNTpTOjACVihJd5wdMLxL55jFE=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b h1:DeP6CzLozsd1MFSOf/Xo3FoBqROW6YZ8fq5ayR3KPwM=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240802071655-9fd2ddd5158b/go.mod h1:fCwb573m5JgCpuAZ+MK3Kx4WIV+q60TaPRu/m8fCcr0=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338 h1:a45+o47CqEksgeyX1IBbWoxPojIVLOIARxH9uBsHe70=
github.com/babylonlabs-io/babylon-sdk/demo v0.0.0-20240813062800-00e11abf5338/go.mod h1:QqEn1sL4RPG7DJ94XFYvuvEELml64s5XwPQpTayXJss=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338 h1:48YwlQpQELyuVb7D/r2NMh7Op8K9WYMcnKUpeH3a+5c=
github.com/babylonlabs-io/babylon-sdk/x v0.0.0-20240813062800-00e11abf5338/go.mod h1:WJlZy0RYCtyBFeO1mr0Tlo02csrlCAQgzmp4+NVX14g=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
Expand Down

0 comments on commit b099d9a

Please sign in to comment.