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

[TECHDEBT] Consolidate & encapsulate ValidatorMap logic - (Issue #203) #402

Merged
merged 173 commits into from
Jan 9, 2023

Conversation

deblasis
Copy link
Contributor

@deblasis deblasis commented Dec 15, 2022

Description

Issue

Fixes #203

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

List of changes

  • Refactored so that references to modules.ValidatorMap are removed/internalized within Consensus
  • [WIP] Make sure that the debug client can discover the validators in LocalNet

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)

@deblasis
Copy link
Contributor Author

deblasis commented Jan 4, 2023

@Olshansk all yours again buddy 🎾 😀

@@ -130,7 +130,7 @@ rebuild_client_start: docker_check ## Rebuild and run a client daemon which is o

.PHONY: client_connect
client_connect: docker_check ## Connect to the running client debugging daemon
docker exec -it client /bin/bash -c "go run -tags=debug app/client/*.go debug"
docker exec -it client /bin/bash -c "POCKET_P2P_IS_CLIENT_ONLY=true go run -tags=debug app/client/*.go debug"
Copy link
Member

Choose a reason for hiding this comment

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

Otherwise I can put it at the root of the config and be POCKET_CLIENT_DEBUG_MODE (probably better if we think it can be useful for other purposes, I can't think about anything else currently

Let's do this

runtime/configs/proto/p2p_config.proto Show resolved Hide resolved
p2p/raintree/network.go Outdated Show resolved Hide resolved
p2p/module.go Show resolved Hide resolved
m.network = stdnetwork.NewNetwork(m.GetBus(), m.p2pCfg, addrbookProvider, currentHeightProvider)
}

if m.p2pCfg.GetIsClientOnly() {
Copy link
Member

Choose a reason for hiding this comment

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

Inside of p2p/raintree/network.go we check bus == nil, whereas here we check if the cfg is client only.

I'm beginning to fear a bit that the lack of a bus (or even a debug bus) is adding lots of checks just because we are logging telemetry.

Do you see a better approach (in this PR or followup) to simplify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair point that I had kinda already addressed in #425 but now with this nudge I have improved further:
bd85dd4

Basically now we fallback to a noopTelemetry module in there and also we always have a bus.
Therefore the check is not needed anymore.

Also, you made me think harder about the debugclient flag and the fact that I was using an environment variable to override it. Nonsense, inside the CLI we know we are initializing a debug client 🤦‍♂️ so I have added the proper configuration option.

p2p/providers/addrbook_provider/debug/addrbook_provider.go Outdated Show resolved Hide resolved
p2p/providers/addrbook_provider/debug/addrbook_provider.go Outdated Show resolved Hide resolved
@deblasis deblasis requested a review from Olshansk January 9, 2023 19:05
@deblasis
Copy link
Contributor Author

deblasis commented Jan 9, 2023

Hey @Olshansk, this is ready for another pass.
One thing worth mentioning is that LocalNet has the bug related to nonceSet concurrency for which we have fixes incoming in, I believe in not 1 but 2 PRs (#425 and #404) so no point applying here as well I guess. If you disagree I can cherry-pick.

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.

If you disagree I can cherry-pick.

No need to ⛏️ any 🍒 .

I believe in not 1 but 2 PRs (#425 and #404) so no point applying here as well I guess.

Hahaha, sounds like a commercial

@deblasis deblasis merged commit a86c0e6 into main Jan 9, 2023
@deblasis deblasis deleted the issue/203-validatorMap branch January 9, 2023 22:46
deblasis added a commit that referenced this pull request Jan 10, 2023
…t - (Issue #331) (#425)

## Description

This PR builds upon #402 and removes `validatorMap` from the
`consensusModule` struct, encapsulating the logic so that the validator
set is dynamic and retrieved from the `persistence` module.

Also, since the change introduced the natural dependency on
`persistence`, it made me question and revisit the way the modules
register themselves with the `bus` and also how the modules are
instantiated.

In an effort to simply the codebase and testing, while we improve the
way we do dependency injection, the modules now are instantiated with a
`bus` that will allow them to access to all the dependencies they need.

Previously the modules required a `runtimeMgr` in their constructor and
the bus registration was handled like an after-thought.

## Issue

Fixes #331 

## Type of change

Please mark the relevant option(s):

- [x] New feature, functionality or library
- [ ] Bug fix
- [x] Code health or cleanup
- [x] Major breaking change
- [ ] Documentation
- [ ] Other <!-- add details here if it a different type of change -->

## List of changes

- Removed `validatorMap` from `consensusModule` and encapsulated the
logic so that it's dynamic, per-height and sourced from `persistence`
- Refactored module registration in `bus`
- Refactored modules instantiation and DI (`runtimeMgr` -> `bus`)
- The `runtimeMgr` is now a dependency and it can be accessed via the
bus
- Minor improvements in tests

## Testing

- [x] `make develop_test`
- [x]
[LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md)
w/ all of the steps outlined in the `README`

## Required Checklist

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

### If Applicable Checklist
- [x] I have updated the corresponding README(s); local and/or global
- [x] I have added tests that prove my fix is effective or that my
feature works
- [ ] I have added, or updated,
[mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding
README(s)
- [ ] I have added, or updated, documentation and
[mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*`
if I updated `shared/*`README(s)

Signed-off-by: Alessandro De Blasis <[email protected]>
Co-authored-by: Daniel Olshansky <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code health Nice to have code improvement consensus Consensus specific changes core Core infrastructure - protocol related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

[TECHDEBT] Consolidate & encapsulate ValidatorMap logic
2 participants