Skip to content

Commit

Permalink
Merge branch 'merge/e2e_test/relay_x_relayer_cli' into e2e_test/relay…
Browse files Browse the repository at this point in the history
…-update

* merge/e2e_test/relay_x_relayer_cli:
  fix: supplier client test
  chore: add long command description
  chore: review feedback improvements
  chore: review feedback improvements
  fix: sessiontree store path check
  fix: sessiontree store path check
  refactor: separate tx and query client contexts 🙄
  refactor: relayminer depinject helpers & godoc comments on all constructors
  chore: review feedback improvements
  chore: update anvil service port in make targets
  • Loading branch information
bryanchriswhite committed Nov 15, 2023
2 parents 8c1f5b9 + 3a178b2 commit 98a1854
Show file tree
Hide file tree
Showing 12 changed files with 254 additions and 119 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -366,19 +366,20 @@ supplier_stake: ## Stake tokens for the supplier specified (must specify the APP
supplier1_stake: ## Stake supplier1 (also staked in genesis)
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier1 SERVICES="anvil;http://localhost:8548,svc1;http://localhost:8081" make supplier_stake
# TODO_IMPROVE(#180): Make sure genesis-staked actors are available via AccountKeeper
SUPPLIER=supplier1 SERVICES="anvil;http://localhost:8545,svc1;http://localhost:8081" make supplier_stake

.PHONY: supplier2_stake
supplier2_stake: ## Stake supplier2
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier2 SERVICES="anvil;http://localhost:8548,svc2;http://localhost:8082" make supplier_stake
SUPPLIER=supplier2 SERVICES="anvil;http://localhost:8545,svc2;http://localhost:8082" make supplier_stake

.PHONY: supplier3_stake
supplier3_stake: ## Stake supplier3
# TODO_TECHDEBT(#179): once `relayminer` service is added to tilt, this hostname should point to that service.
# I.e.: replace `localhost` with `relayminer` (or whatever the service's hostname is).
SUPPLIER=supplier3 SERVICES="anvil;http://localhost:8548,svc3;http://localhost:8083" make supplier_stake
SUPPLIER=supplier3 SERVICES="anvil;http://localhost:8545,svc3;http://localhost:8083" make supplier_stake

.PHONY: supplier_unstake
supplier_unstake: ## Unstake an supplier (must specify the SUPPLIER env var)
Expand Down
3 changes: 3 additions & 0 deletions pkg/client/block/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ type eventBytesToBlockMapFn = func(
) (client.Block, bool)

// NewBlockClient creates a new block client from the given dependencies and cometWebsocketURL.
//
// Required dependencies:
// - client.EventsQueryClient
func NewBlockClient(
ctx context.Context,
deps depinject.Config,
Expand Down
5 changes: 5 additions & 0 deletions pkg/client/events_query/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func (ebc *eventsBytesAndConn) Close() {
_ = ebc.conn.Close()
}

// NewEventsQueryClient returns a new events query client which is used to
// subscribe to on-chain events matching the given query.
//
// Available options:
// - WithDialer
func NewEventsQueryClient(cometWebsocketURL string, opts ...client.EventsQueryClientOption) client.EventsQueryClient {
evtClient := &eventsQueryClient{
cometWebsocketURL: cometWebsocketURL,
Expand Down
9 changes: 9 additions & 0 deletions pkg/client/tx/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ type TxEvent struct {
// validateConfigAndSetDefaults method.
// 5. Subscribes the client to its own transactions. This step might be
// reconsidered for relocation to a potential Start() method in the future.
//
// Required dependencies:
// - client.TxContext
// - client.EventsQueryClient
// - client.BlockClient
//
// Available options:
// - WithSigningKeyName
// - WithCommitTimeoutHeightOffset
func NewTxClient(
ctx context.Context,
deps depinject.Config,
Expand Down
15 changes: 9 additions & 6 deletions pkg/client/tx/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
authclient "github.com/cosmos/cosmos-sdk/x/auth/client"

"github.com/pokt-network/poktroll/pkg/client"
"github.com/pokt-network/poktroll/pkg/relayer"
)

var _ client.TxContext = (*cosmosTxContext)(nil)
Expand All @@ -21,7 +22,7 @@ var _ client.TxContext = (*cosmosTxContext)(nil)
type cosmosTxContext struct {
// Holds cosmos-sdk client context.
// (see: https://pkg.go.dev/github.com/cosmos/[email protected]/client#Context)
clientCtx cosmosclient.Context
clientCtx relayer.TxClientContext
// Holds the cosmos-sdk transaction factory.
// (see: https://pkg.go.dev/github.com/cosmos/[email protected]/client/tx#Factory)
txFactory cosmostx.Factory
Expand All @@ -30,6 +31,10 @@ type cosmosTxContext struct {
// NewTxContext initializes a new cosmosTxContext with the given dependencies.
// It uses depinject to populate its members and returns a client.TxContext
// interface type.
//
// Required dependencies:
// - cosmosclient.Context
// - cosmostx.Factory
func NewTxContext(deps depinject.Config) (client.TxContext, error) {
txCtx := cosmosTxContext{}

Expand All @@ -41,8 +46,6 @@ func NewTxContext(deps depinject.Config) (client.TxContext, error) {
return nil, err
}

txCtx.clientCtx = cosmosclient.Context(txCtx.clientCtx)

return txCtx, nil
}

Expand All @@ -62,7 +65,7 @@ func (txCtx cosmosTxContext) SignTx(
) error {
return authclient.SignTx(
txCtx.txFactory,
txCtx.clientCtx,
cosmosclient.Context(txCtx.clientCtx),
signingKeyName,
txBuilder,
offline, overwriteSig,
Expand All @@ -82,8 +85,8 @@ func (txCtx cosmosTxContext) EncodeTx(txBuilder cosmosclient.TxBuilder) ([]byte,
// BroadcastTx broadcasts the given transaction to the network, blocking until the check-tx
// ABCI operation completes and returns a TxResponse of the transaction status at that point in time.
func (txCtx cosmosTxContext) BroadcastTx(txBytes []byte) (*cosmostypes.TxResponse, error) {
return txCtx.clientCtx.BroadcastTxAsync(txBytes)
//return txCtx.clientCtx.BroadcastTxSync(txBytes)
clientCtx := cosmosclient.Context(txCtx.clientCtx)
return clientCtx.BroadcastTxAsync(txBytes)
}

// QueryTx queries the transaction based on its hash and optionally provides proof
Expand Down
Loading

0 comments on commit 98a1854

Please sign in to comment.