From f7f7f246a76f40cec30e31d1367b70af72329c41 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Mon, 2 Sep 2024 18:32:21 -0500 Subject: [PATCH] rename --- client/cmbft_client_wrapper.go | 2 +- client/cmbft_consensus.go | 34 +++++++++++------------------ client/consensus.go | 20 +++-------------- interchaintest/feegrant_test.go | 4 ++-- relayer/chains/penumbra/provider.go | 6 ++--- 5 files changed, 22 insertions(+), 44 deletions(-) diff --git a/client/cmbft_client_wrapper.go b/client/cmbft_client_wrapper.go index 3aae0e2f3..4f4c95f98 100644 --- a/client/cmbft_client_wrapper.go +++ b/client/cmbft_client_wrapper.go @@ -1,4 +1,4 @@ -package client +package rclient import ( "context" diff --git a/client/cmbft_consensus.go b/client/cmbft_consensus.go index 365557932..15aa5fe3d 100644 --- a/client/cmbft_consensus.go +++ b/client/cmbft_consensus.go @@ -1,4 +1,4 @@ -package client +package rclient import ( "context" @@ -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) @@ -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) @@ -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 { @@ -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 { @@ -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 { @@ -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) @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { diff --git a/client/consensus.go b/client/consensus.go index 21e565af5..e680052a5 100644 --- a/client/consensus.go +++ b/client/consensus.go @@ -1,4 +1,4 @@ -package client +package rclient import ( "context" @@ -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) @@ -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, @@ -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"` } @@ -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"` diff --git a/interchaintest/feegrant_test.go b/interchaintest/feegrant_test.go index 9cdf8bc46..584df4b64 100644 --- a/interchaintest/feegrant_test.go +++ b/interchaintest/feegrant_test.go @@ -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" @@ -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 { diff --git a/relayer/chains/penumbra/provider.go b/relayer/chains/penumbra/provider.go index 4324740d2..cb1c4299c 100644 --- a/relayer/chains/penumbra/provider.go +++ b/relayer/chains/penumbra/provider.go @@ -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" @@ -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 @@ -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