Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Sep 2, 2024
1 parent 1509ba6 commit f7f7f24
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 44 deletions.
2 changes: 1 addition & 1 deletion client/cmbft_client_wrapper.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client
package rclient

import (
"context"
Expand Down
34 changes: 13 additions & 21 deletions client/cmbft_consensus.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client
package rclient

import (
"context"
Expand All @@ -12,10 +12,9 @@ import (
rbytes "github.com/cosmos/relayer/v2/client/bytes"
)

// ConsensusRelayerI is the itnerface we will use across the relayer so we can swap out the underlying consensus engine client.
var _ ConsensusClient = (*CometRPCClient)(nil)

// GetBlock implements ConsensusRelayerI.
// GetBlock implements ConsensusClient.
func (r CometRPCClient) GetBlockTime(ctx context.Context, height uint64) (time.Time, error) {
h := int64(height)

Expand All @@ -27,7 +26,7 @@ func (r CometRPCClient) GetBlockTime(ctx context.Context, height uint64) (time.T
return b.Block.Header.Time, nil
}

// GetBlockResults implements ConsensusRelayerI.
// GetBlockResults implements ConsensusClient.
func (r CometRPCClient) GetBlockResults(ctx context.Context, height uint64) (*BlockResults, error) {
h := int64(height)
br, err := r.BlockResults(ctx, &h)
Expand All @@ -40,7 +39,7 @@ func (r CometRPCClient) GetBlockResults(ctx context.Context, height uint64) (*Bl
}, nil
}

// GetABCIQuery implements ConsensusRelayerI.
// GetABCIQuery implements ConsensusClient.
func (r CometRPCClient) GetABCIQuery(ctx context.Context, queryPath string, data bytes.HexBytes) (*ABCIQueryResponse, error) {
resp, err := r.ABCIQuery(ctx, queryPath, data)
if err != nil {
Expand All @@ -52,23 +51,16 @@ func (r CometRPCClient) GetABCIQuery(ctx context.Context, queryPath string, data
}, nil
}

// GetTx implements ConsensusRelayerI.
// GetTx implements ConsensusClient.
func (r CometRPCClient) GetTx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error) {
resp, err := r.Tx(ctx, hash, prove)
if err != nil {
return nil, fmt.Errorf("failed to get tx: %w", err)
}
// return &Transaction{
// Height: uint64(resp.Height),
// TxHash: resp.Hash,
// Code: resp.TxResult.Code,
// Data: string(resp.TxResult.Data),
// Events: resp.TxResult.Events,
// }, nil
return resp, nil
}

// GetTxSearch implements ConsensusRelayerI.
// GetTxSearch implements ConsensusClient.
func (r CometRPCClient) GetTxSearch(ctx context.Context, query string, prove bool, page *int, perPage *int, orderBy string) (*ResultTxSearch, error) {
resp, err := r.TxSearch(ctx, query, prove, page, perPage, orderBy)
if err != nil {
Expand All @@ -80,7 +72,7 @@ func (r CometRPCClient) GetTxSearch(ctx context.Context, query string, prove boo
}, nil
}

// GetBlockSearch implements ConsensusRelayerI.
// GetBlockSearch implements ConsensusClient.
func (r CometRPCClient) GetBlockSearch(ctx context.Context, query string, page *int, perPage *int, orderBy string) (*coretypes.ResultBlockSearch, error) {
resp, err := r.BlockSearch(ctx, query, page, perPage, orderBy)
if err != nil {
Expand All @@ -89,7 +81,7 @@ func (r CometRPCClient) GetBlockSearch(ctx context.Context, query string, page *
return resp, nil
}

// GetCommit implements ConsensusRelayerI.
// GetCommit implements ConsensusClient.
func (r CometRPCClient) GetCommit(ctx context.Context, height uint64) (*coretypes.ResultCommit, error) {
h := int64(height)
c, err := r.Commit(ctx, &h)
Expand All @@ -99,7 +91,7 @@ func (r CometRPCClient) GetCommit(ctx context.Context, height uint64) (*coretype
return c, nil
}

// GetValidators implements ConsensusRelayerI.
// GetValidators implements ConsensusClient.
func (r CometRPCClient) GetValidators(ctx context.Context, height *int64, page *int, perPage *int) (*ResultValidators, error) {
v, err := r.Validators(ctx, height, page, perPage)
if err != nil {
Expand All @@ -121,7 +113,7 @@ func (r CometRPCClient) GetValidators(ctx context.Context, height *int64, page *
}, nil
}

// DoBroadcastTxAsync implements ConsensusRelayerI.
// DoBroadcastTxAsync implements ConsensusClient.
func (r CometRPCClient) DoBroadcastTxAsync(ctx context.Context, tx tmtypes.Tx) (*ResultBroadcastTx, error) {
b, err := r.BroadcastTxAsync(ctx, tx)
if err != nil {
Expand All @@ -136,7 +128,7 @@ func (r CometRPCClient) DoBroadcastTxAsync(ctx context.Context, tx tmtypes.Tx) (
}, nil
}

// DoBroadcastTxSync implements ConsensusRelayerI.
// DoBroadcastTxSync implements ConsensusClient.
func (r CometRPCClient) DoBroadcastTxSync(ctx context.Context, tx tmtypes.Tx) (*ResultBroadcastTx, error) {
b, err := r.BroadcastTxSync(ctx, tx)
if err != nil {
Expand All @@ -151,7 +143,7 @@ func (r CometRPCClient) DoBroadcastTxSync(ctx context.Context, tx tmtypes.Tx) (*
}, nil
}

// GetABCIQueryWithOptions implements ConsensusRelayerI.
// GetABCIQueryWithOptions implements ConsensusClient.
func (r CometRPCClient) GetABCIQueryWithOptions(ctx context.Context, path string, data bytes.HexBytes, opts rpcclient.ABCIQueryOptions) (*coretypes.ResultABCIQuery, error) {
q, err := r.ABCIQueryWithOptions(ctx, path, data, opts)
if err != nil {
Expand All @@ -160,7 +152,7 @@ func (r CometRPCClient) GetABCIQueryWithOptions(ctx context.Context, path string
return q, nil
}

// GetStatus implements ConsensusRelayerI.
// GetStatus implements ConsensusClient.
func (r CometRPCClient) GetStatus(ctx context.Context) (*Status, error) {
s, err := r.Status(ctx)
if err != nil {
Expand Down
20 changes: 3 additions & 17 deletions client/consensus.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package client
package rclient

import (
"context"
Expand All @@ -15,6 +15,7 @@ import (
rbytes "github.com/cosmos/relayer/v2/client/bytes"
)

// TODO(reece): get off CometBFT types into internal relayer.
type ConsensusClient interface {
GetBlockTime(ctx context.Context, height uint64) (time.Time, error)
GetStatus(ctx context.Context) (*Status, error)
Expand All @@ -34,17 +35,13 @@ type ConsensusClient interface {
) (*ResultTxSearch, error)
DoBroadcastTxSync(ctx context.Context, tx tmtypes.Tx) (*ResultBroadcastTx, error)
DoBroadcastTxAsync(ctx context.Context, tx tmtypes.Tx) (*ResultBroadcastTx, error)

// TODO: migrate with v2
GetTx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error) // resp (Events), err != nil - does this need its own tm store? or does the manager have context to this

GetTx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error)
GetBlockSearch(
ctx context.Context,
query string,
page, perPage *int,
orderBy string,
) (*coretypes.ResultBlockSearch, error)

GetCommit(ctx context.Context, height uint64) (*coretypes.ResultCommit, error)
GetABCIQueryWithOptions(
ctx context.Context,
Expand All @@ -60,7 +57,6 @@ type Status struct {
}

type BlockResults struct {
// TODO: ideally we get off of this into our own internal type. Then the ConsensusRelayerI can have methods to convert
FinalizeBlockEvents []abci.Event `json:"finalize_block_events"`
TxsResults []*abci.ExecTxResult `json:"txs_results"`
}
Expand All @@ -75,16 +71,6 @@ func (q ABCIQueryResponse) ValueCleaned() string {
return strings.ReplaceAll(strings.TrimSpace(string(q.Value)), "\u0010", "")
}

// TODO: can't do this yet as the cosmos-sdk side in v0.50 is tied to cometbft
// type Transaction struct {
// Height uint64
// TxHash []byte
// Code uint32
// Data string
// Events []abci.Event // TODO: []provider.RelayerEvent
// Tx cmtypes.Tx `json:"tx"`
// }

// coretypes.ResultTxSearch
type ResultTxSearch struct {
Txs []*coretypes.ResultTx `json:"txs"`
Expand Down
4 changes: 2 additions & 2 deletions interchaintest/feegrant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/cosmos/go-bip39"
transfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
chantypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types"
"github.com/cosmos/relayer/v2/client"
rclient "github.com/cosmos/relayer/v2/client"
"github.com/cosmos/relayer/v2/relayer"
"github.com/cosmos/relayer/v2/relayer/chains/cosmos"
"github.com/cosmos/relayer/v2/relayer/processor"
Expand Down Expand Up @@ -538,7 +538,7 @@ func TestRelayerFeeGrant(t *testing.T) {
}
}

func TxWithRetry(ctx context.Context, client client.ConsensusClient, hash []byte) (*coretypes.ResultTx, error) {
func TxWithRetry(ctx context.Context, client rclient.ConsensusClient, hash []byte) (*coretypes.ResultTx, error) {
var err error
var res *coretypes.ResultTx
if err = retry.Do(func() error {
Expand Down
6 changes: 3 additions & 3 deletions relayer/chains/penumbra/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
tmclient "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
cwrapper "github.com/cosmos/relayer/v2/client"
rclient "github.com/cosmos/relayer/v2/client"
"github.com/cosmos/relayer/v2/relayer/codecs/ethermint"
"github.com/cosmos/relayer/v2/relayer/provider"
"github.com/strangelove-ventures/cometbft-client/client"
Expand Down Expand Up @@ -142,7 +142,7 @@ type PenumbraProvider struct {
PCfg PenumbraProviderConfig
Keybase keyring.Keyring
KeyringOptions []keyring.Option
RPCClient cwrapper.CometRPCClient
RPCClient rclient.CometRPCClient
LightProvider provtypes.Provider
Input io.Reader
Output io.Writer
Expand Down Expand Up @@ -354,7 +354,7 @@ func (cc *PenumbraProvider) setRpcClient(onStartup bool, rpcAddr string, timeout
return err
}

cc.RPCClient = cwrapper.NewRPCClient(c)
cc.RPCClient = rclient.NewRPCClient(c)

// Only check status if not on startup, to ensure the relayer will not block on startup.
// All subsequent calls will perform the status check to ensure RPC endpoints are rotated
Expand Down

0 comments on commit f7f7f24

Please sign in to comment.