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

[P2P / runtime] chore: p2p connection type #450

Merged
merged 8 commits into from
Jan 25, 2023

Conversation

bryanchriswhite
Copy link
Contributor

@bryanchriswhite bryanchriswhite commented Jan 19, 2023

Description

Replaces boolean IsEmptyConnectionType with enum ConnectionType in P2PConfig to enable future support for additional connection types.

Issue

Fixes #268

Type of change

Please mark the relevant option(s):

  • New feature, functionality or library
  • Bug fix
  • Code health or cleanup
  • Major breaking change
  • Documentation
  • Other: chore

List of changes

  • move ConnectionType enum into its own package to avoid a cyclic import between configs and defaults packages (i.e. configs -> defaults -> configs) in the resulting, generated go package
  • update makefile protogen_local target to build additional proto file and include it in the import path for runtime/configs/proto/p2p_config.proto
  • replace P2PConfig#IsEmptyConnectionType with P2PConfig#ConnectionType
  • replace DefaultP2PIsEmptyConnectionType with DefaultP2PConnectionType

Testing

  • make develop_test
  • LocalNet w/ all of the steps outlined in the README

Required Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have tested my changes using the available tooling
  • I have updated the corresponding CHANGELOG

If Applicable Checklist

  • I have updated the corresponding README(s); local and/or global
  • I have added tests that prove my fix is effective or that my feature works
  • I have added, or updated, mermaid.js diagrams in the corresponding README(s)
  • I have added, or updated, documentation and mermaid.js diagrams in shared/docs/* if I updated shared/*README(s)

@bryanchriswhite bryanchriswhite added core Core infrastructure - protocol related p2p P2P specific changes labels Jan 19, 2023
@bryanchriswhite bryanchriswhite self-assigned this Jan 19, 2023
@bryanchriswhite bryanchriswhite force-pushed the chore/p2p-connection-type branch 3 times, most recently from 6d12436 to 787606c Compare January 20, 2023 11:46
@bryanchriswhite bryanchriswhite marked this pull request as ready for review January 20, 2023 12:30
Makefile Outdated
@@ -244,7 +244,8 @@ protogen_local: go_protoc-go-inject-tag ## Generate go structures for all of the
$(PROTOC) -I=./shared/codec/proto --go_out=./shared/codec ./shared/codec/proto/*.proto

# Runtime
$(PROTOC_SHARED) -I=./runtime/configs/proto --go_out=./runtime/configs ./runtime/configs/proto/*.proto
protoc --go_opt=paths=source_relative -I=./runtime/configs/types/proto --go_out=./runtime/configs/types ./runtime/configs/types/proto/*.proto --experimental_allow_proto3_optional
Copy link
Member

Choose a reason for hiding this comment

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

Could we use the PROTOC_SHARED helper here?

@@ -0,0 +1,10 @@
syntax = "proto3";
Copy link
Member

Choose a reason for hiding this comment

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

I think consolidating this with runtime/configs/proto/p2p_config.proto would be cleaner. Wdyt?

Copy link
Contributor Author

@bryanchriswhite bryanchriswhite Jan 23, 2023

Choose a reason for hiding this comment

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

I agree that it would be simpler for P2PConfig and ConnectionTypes to be in the same package (as it was before my changes). There's a slight hangup though in the runtime/defaults package. When replacing defaults.DefaultP2PIsEmptyConnectionType with defaults.DefaultP2PConnectionType we need to import the ConnectionType enum, which causes a cyclic import (as configs/config.go is currently consuming defaults). I'm not sure there's much that can be done in the way of consolidation so long as configs is importing defaults and config.go shares a package with the ConnectionType generated proto code. We could, of course, move more of the runtime/configs package into the new one (e.g. P2PConfig). The most aggressive version of this would result in separating the all the generated protobuf into the new package. While I think, in principal, this is probably the right direction to go, it would require many more changes to account for imports of other configs proto types.

Another alternative would be to consider moving (at least) the ConnectionType enum to the shared protobuf files (e.g. shared/types/proto) as this would necessarily change its package but makes less sense in my opinion as I don't think it's a fair to characterize this enum as "shared" based on current usage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also very open to suggestions on better names for both the go and proto package (types and conn, respectively, as of 33aaafd).

Copy link
Member

Choose a reason for hiding this comment

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

Appreciate the explanation @bryanchriswhite. I understand the point around consolidation and would say that lets just keep it as you have it.

The primary goal of this issue of using enums has been achieved relatively cleanly, and we'll have a lot more opportunities to clean up the code in the future.

The name lgtm!

@Olshansk
Copy link
Member

@bryanchriswhite Friendly reminder :)

Screenshot 2023-01-23 at 6 31 24 PM

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.

One more minor change request. See the definition of PROTOC as to why I'm suggesting it.

The only reason I'm not approving yet is that I saw you didn't check the LocalNet checkbox of the testing section. Until we have automated E2E tests, can you confirm that works?

Makefile Outdated Show resolved Hide resolved
@@ -0,0 +1,10 @@
syntax = "proto3";
Copy link
Member

Choose a reason for hiding this comment

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

Appreciate the explanation @bryanchriswhite. I understand the point around consolidation and would say that lets just keep it as you have it.

The primary goal of this issue of using enums has been achieved relatively cleanly, and we'll have a lot more opportunities to clean up the code in the future.

The name lgtm!

@bryanchriswhite
Copy link
Contributor Author

bryanchriswhite commented Jan 24, 2023

One more minor change request. See the definition of PROTOC as to why I'm suggesting it.

Thanks for elaborating, I was not paying close enough attention and missed the detail there. 😅

The only reason I'm not approving yet is that I saw you didn't check the LocalNet checkbox of the testing section. Until we have automated E2E tests, can you confirm that works?

No worries, regarding localnet: I made an attempt to follow the localnet instructions but lost the thread around steps 4/5:

  1. Check the state of each node
  2. Trigger the next view to ensure everything is working

I'm not sure what "working" looks like yet (expected behavior), is any other documentation that elaborates on this?

@Olshansk
Copy link
Member

I'm not sure what "working" looks like yet (expected behavior), is any other documentation that elaborates on this?

Discussed offline but covering here.

The gif in https://github.com/pokt-network/pocket/blob/main/docs/development/README.md is a bit outdated but that's the closest "source of truth" we have for working at the moment. Simply making sure that the height increases from the logs.

We'll automate the test and improve the docs over time, but a manual sanity check of that for now should suffice.

@bryanchriswhite
Copy link
Contributor Author

@Olshansk after actually taking a second to read a bit of the makefile and get more familiar with the docker-compose file, I gave it another go and things seems to be making more sense, and indeed working. 😄 I think maybe what I was seeing before was related to timeouts but having no awareness of them (I'm blaming sensory overload 😅).

@bryanchriswhite
Copy link
Contributor Author

bryanchriswhite commented Jan 25, 2023

FYI: that last force-push was me changing my mind about how I think it makes sense to handle merge conflict resolutions in changelogs genrally. In this case the upstream change had a newer date, but the same unreleased version number.

For anyone who isn't aware, the words "force-pushed" in the comment GH entry is a link to the diff between the mentioned commits:

image

I've collected my thoughts on the matter and opened #461.

runtime/docs/CHANGELOG.md Outdated Show resolved Hide resolved
@Olshansk
Copy link
Member

@bryanchriswhite Make sure to squash-and-merge the PR with the Github's PR description as the commit message.

@bryanchriswhite bryanchriswhite merged commit e22d619 into main Jan 25, 2023
@bryanchriswhite bryanchriswhite deleted the chore/p2p-connection-type branch January 25, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core infrastructure - protocol related p2p P2P specific changes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[TECHDEBT] [P2P] Conntype as enum
2 participants