Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servicer & PocketNetworkClient #9

Closed
wants to merge 86 commits into from
Closed

Servicer & PocketNetworkClient #9

wants to merge 86 commits into from

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Sep 8, 2023

NOTE: This will be superseded by #19

bryanchriswhite and others added 30 commits September 5, 2023 13:08
* main:
  fix: add -s nested make calls which populate vars
  Standardised RPC port across localnet and testnet
adds relay worker tests and relay proto messages
* pokt/miner:
  removes outdated comment
  removes unnecessary break in session manager Start
  adds logger to relayer module
  relay worker tests passing
  [wip] relay tests failed successfully
  [wip] go mod tidy
  [wip] more protobuf error fixes and cleanup
  [wip] protobuf fixes
  moving mining logic to miner module
  add relay mining logic
  chore: stub out `rollkitPocketNetworkClient` impl.
  refactor: move servicer client to client pkg
  wip - adding in types and harness
  wip: port cmt-pokt servicer & deps
  test: update hardcoded test keypairs to secp256k1
  chore: adapt keys to cosmos secp256k1
  chore: port V1 crypto pkg
@bryanchriswhite bryanchriswhite changed the title Servicer & PocketNetworkClient [WIP - DO NOT MERGE] Servicer & PocketNetworkClient Sep 12, 2023
clientCtx cosmosClient.Context
}

func NewLocalCosmosPocketClient() modules.PocketNetworkClient {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk #ReviewMe This is the PocketNetworkClient implementation that would be used by the servicer command (i.e. pokrolld "internal" servicer).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good at a high level.

I think that all internal business logic that requires access to state or leads to state transitions should tie into the keeper: #19 (comment)

) <-chan types.Maybe[*types.TxResult] {
resultCh := make(chan types.Maybe[*types.TxResult], 1)

// TODO_THIS_COMMIT: provide encoding config via DI (?)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO_THIS_COMMIT: provide encoding config via DI (?)

msg cosmosTypes.Msg,
) <-chan types.Maybe[*types.TxResult] {
// construct tx
// TODO_THIS_COMMIT: use DI to get updated client context!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO_THIS_COMMIT: use DI to get updated client context!


var _ modules.ServicerClient = &servicerClient{}

type servicerClient struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk #ReviewMe Not much to review here but wanted to call it out regardless. This is a stub for the implementation of the servicer's RPC client. This would be used by the end client (or test) to request relays from the servicer.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "RPC client" is fundamentally an "off-chain". In other words a "read" in the context of the query/message server.

I think it should be scaffolded as a query using ignite.

The Query Server [1] has access to the keeper, which can in turn update the SMT.

[1] https://docs.cosmos.network/main/building-modules/query-services

ctx := context.WithValue(cmd.Context(), PoktrollDepInjectorContextKey, injector)
cmd.SetContext(ctx)

// get key name from clientCtx
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// get key name from clientCtx

- remove irrelevant comment
- add comment re: ensuring key exists
- rename `servicer` to `srvcr` to avoid collision with imported package name
servicer/cmd.go Outdated
}

func servicerCmd(cmd *cobra.Command, args []string) error {
injector := di.NewInjector()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk #ReviewMe Here we're initializing our dependency injection and subsequently providing the cosmos-sdk dependencies for the localCosmosPocketClient implementation of PocketNetworkClient:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the injector is now deprecated :)

"poktroll/runtime/di"
)

type servicer struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk #ReviewMe This is the servicer module implementation.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

No need to have a logger, but the other types should be embedded in the servicer module's keeper struct.

"poktroll/x/poktroll/types"
)

type sessionManager struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Olshansk #ReviewMe This is the SessionManager which is used in the Servicer to pass an observable which emits closed sessions to the Miner.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There will be some iterating we'll be doing here that I think will simplify it quite a bit and make it a lot more stateless.

See the session module I just merged to main.

@@ -0,0 +1,77 @@
package utils
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All file_utils functions seem be be unused (i.e. it's save to remove them if we want).

closestKey []byte,
closestValueHash []byte,
closestSum uint64,
// TODO: what type should `claim` be?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: what type should `claim` be?

closestSum uint64,
// TODO: what type should `claim` be?
proof *smt.SparseMerkleProof,
err error,
Copy link
Contributor Author

@bryanchriswhite bryanchriswhite Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@red-0ne why does this receive an error?

)

type remoteCosmosPocketClient struct {
//privateKey *secp256k1.PrivKey
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//privateKey *secp256k1.PrivKey

_ modules.PocketNetworkClient = &remoteCosmosPocketClient{}
)

type remoteCosmosPocketClient struct {
Copy link
Contributor Author

@bryanchriswhite bryanchriswhite Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unused at the moment but is an example of what would be required after the servicer becomes external.

closestKey []byte,
closestValueHash []byte,
closestSum uint64,
// TODO: what type should `claim` be?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// TODO: what type should `claim` be?

Copy link
Member

@Olshansk Olshansk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bryanchriswhite I realize this is now deprecated but just left comments in the places you asked to review. I think it was a great first iteration and #19 is getting even closer.

The newer PR is pretty close to a first iteration and I think even the leakage of the txconfig and context can be cleaned up after we get the first version into main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants