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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
173 commits
Select commit Hold shift + click to select a range
79e988c
feat(Messaging): new events and message
deblasis Dec 4, 2022
f925a1f
feat(Consensus): the pacemaker emits Height related events
deblasis Dec 4, 2022
27859db
feat(P2P): reacts to BeforeHeightChanged and broadcasts addrb
deblasis Dec 4, 2022
e19041b
feat(Messaging): eventTypes for new messages/events
deblasis Dec 4, 2022
550c47e
chore(P2P): ErrUnknownEventType
deblasis Dec 4, 2022
3dc5ffd
feat(P2P): HandleEvent
deblasis Dec 4, 2022
3c9cbc7
feat(Shared): event handling for height events and addressbook
deblasis Dec 4, 2022
a4abab8
docs(Consensus): changelog
deblasis Dec 4, 2022
4d01838
docs(Shared): changelog
deblasis Dec 4, 2022
12ee0ec
test(Consensus): P2PMock fix (HandleEvent)
deblasis Dec 4, 2022
520b8b9
feat(P2P): raintree mempool map not unbounded anymore
deblasis Dec 4, 2022
caaad9c
docs(P2P): changelog
deblasis Dec 4, 2022
9506419
feat(P2P): raintree now allows ephemeral peersmanager
deblasis Dec 5, 2022
0cf393c
docs(P2P): changelog
deblasis Dec 5, 2022
3fdc817
feat(P2P): AddrBookProvider
deblasis Dec 5, 2022
10a1bb6
test(P2P): fix tests
deblasis Dec 5, 2022
5a7c14c
fix(P2P): fix client P2P.Start() 💩
deblasis Dec 5, 2022
f3df734
feat(Consensus): leader election gets validators from persistence
deblasis Dec 5, 2022
1e14b35
refactor(P2P): renamed ValidatorToXXXX to ActorToXXXX
deblasis Dec 5, 2022
3e5dd59
test(Consensus): fixed tests (mock config due to changed flow)
deblasis Dec 5, 2022
ec77c33
docs(Consensus): changelog
deblasis Dec 5, 2022
8e2866e
docs(P2P): changelog
deblasis Dec 5, 2022
f54875f
chore(P2P): remove TECHDEBT TODOes
deblasis Dec 5, 2022
8e5b367
feat(Consensus): leader election gets validators from persistence
deblasis Dec 5, 2022
53d496b
Merge remote-tracking branch 'upstream/main' into issue/271-p2p-persi…
deblasis Dec 6, 2022
47540f6
test(Consensus): fixed tests (mock config due to changed flow)
deblasis Dec 5, 2022
dbb24d5
test(messaging): contentType tests
deblasis Dec 6, 2022
f9d2a04
Merge remote-tracking branch 'upstream/main' into issue/270-p2p-integ…
deblasis Dec 6, 2022
09aa018
test(consensus): consolidated numValidators and mocks mgmt
deblasis Dec 7, 2022
f773345
fix(pacemaker): logging packing errors if any
deblasis Dec 7, 2022
ea0b2a7
refactor(P2P): nonceSet, nonceList
deblasis Dec 7, 2022
359648a
Revert "feat(Consensus): leader election gets validators from persist…
deblasis Dec 7, 2022
8e146a6
Revert "test(Consensus): fixed tests (mock config due to changed flow)"
deblasis Dec 7, 2022
5c3d939
refactor(P2P): no need to broadcast changes to its addressBook
deblasis Dec 7, 2022
266b47a
docs(P2P): updated changelog (removed AddressBookAtHeight)
deblasis Dec 8, 2022
4ce80bc
feat(P2P): configurable mempool cap via P2PConfig
deblasis Dec 8, 2022
34c0e76
style(P2P): spacing
deblasis Dec 8, 2022
7ac25bb
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 8, 2022
8880c17
style(P2P): validators -> actors
deblasis Dec 8, 2022
dd3020e
fix(consensus): electNextLeaderDeterministicRoundRobin ret err
deblasis Dec 8, 2022
46e20db
Merge remote-tracking branch 'origin/main' into issue/271-p2p-persist…
deblasis Dec 9, 2022
d0aea4c
Merge remote-tracking branch 'origin/main' into issue/270-p2p-integra…
deblasis Dec 9, 2022
ceea403
Merge remote-tracking branch 'origin/issue/271-p2p-persistence-addrbo…
deblasis Dec 9, 2022
8f83720
fix(leader_election): context from utility
deblasis Dec 9, 2022
cf1ef0d
refactor(P2P): MaxMempoolCount
deblasis Dec 9, 2022
1ff01a2
docs(Consensus): changelog
deblasis Dec 10, 2022
f66c621
fix(P2P): GetMaxMempoolCount
deblasis Dec 10, 2022
6bab7eb
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 10, 2022
f70466a
refactor(P2P): v -> a
deblasis Dec 10, 2022
7c05196
test(Consensus): makeMockActors(numValidators)
deblasis Dec 12, 2022
d82b66a
docs(shared): changelog
deblasis Dec 12, 2022
644df90
docs(consensus): changelog
deblasis Dec 12, 2022
d0437a1
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 12, 2022
b53f127
docs(shared): changelog
deblasis Dec 12, 2022
7b8d75b
refactor(Shared): *.bus.* -> *.GetBus().*
deblasis Dec 13, 2022
90f4187
Merge branch 'issue/270-p2p-integration-with-utility-for-addrbook-loo…
deblasis Dec 13, 2022
07a4b40
refactor(Shared): *.bus.* -> *.GetBus().*
deblasis Dec 13, 2022
c74d34e
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' of git…
deblasis Dec 13, 2022
29d3322
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 13, 2022
e0eedd0
style(consensus): rm redundant comment
deblasis Dec 13, 2022
7d69837
Update p2p/raintree/network.go
deblasis Dec 13, 2022
ff1b66d
fix(P2P): removed redundant mock config
deblasis Dec 13, 2022
30e2cfb
refactor(P2P): consistency in imports
deblasis Dec 13, 2022
964360b
refactor(P2P): peersManager flag
deblasis Dec 13, 2022
1084944
docs(P2P): referenced refactoring/techdebt issue
deblasis Dec 13, 2022
36d7129
refactor(persistence): GetAllStakedActors
deblasis Dec 13, 2022
2195594
refactor(persistence): GetAllStakedActors
deblasis Dec 13, 2022
fe80633
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' of git…
deblasis Dec 13, 2022
3adc9a5
refactor(P2P): getAddrBookPerHeight -> getStakedAddrBookAtHeight
deblasis Dec 13, 2022
bcc96c9
fix(Makefile): p2p mocks cleanup and test name typo
deblasis Dec 13, 2022
f3717eb
refactor(P2P): moved transport into its own package
deblasis Dec 13, 2022
8107177
feat(P2P): introduced addrbook_provider
deblasis Dec 13, 2022
cb58f21
refactor(P2P): newPeersManagerWithAddrBookProvider unexported
deblasis Dec 13, 2022
604aa8e
feat(P2P): using addrBook_provider in raintree
deblasis Dec 13, 2022
0e45a5b
refactor(P2P): using addrBook_provider in stdnetwork
deblasis Dec 13, 2022
1fe30a3
refactor(P2P): simplified module init
deblasis Dec 13, 2022
005ecfb
feat(P2P): AddrBookProvider interface
deblasis Dec 13, 2022
adc2783
test(P2P): updated raintree tests and mocks
deblasis Dec 13, 2022
d4b5f7d
refactor(P2P): removed event handling (currently unused)
deblasis Dec 13, 2022
911d01b
refactor(shared): updated event handling
deblasis Dec 13, 2022
9effbe9
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 13, 2022
d53f40a
refactor(P2P): Validator -> Actor
deblasis Dec 13, 2022
0823894
test(P2P): fix tests post renaming
deblasis Dec 13, 2022
86ae4d8
Update p2p/addrbook_provider/getter.go
deblasis Dec 14, 2022
52ea911
Merge remote-tracking branch 'upstream/main' into issue/271-p2p-persi…
deblasis Dec 14, 2022
11a41eb
chore(P2P): improved TODO
deblasis Dec 14, 2022
7c9fe8c
refactor(P2P): improved error handling
deblasis Dec 14, 2022
1c65cb9
refactor(P2P): renamed DefaultP2PMempoolMaxNonces
deblasis Dec 14, 2022
d8fbd35
refactor(Shared): removed height related events, premature. KISS 💋
deblasis Dec 14, 2022
b2fa44f
refactor(persistence): improved GetAllStakedActors, moved from genesi…
deblasis Dec 14, 2022
b71e350
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 14, 2022
908af80
Update consensus/consensus_tests/utils_test.go
deblasis Dec 14, 2022
da0e77c
refactor(persistence): actor -> validator
deblasis Dec 14, 2022
cd8bffe
refactor(P2P): moar validator -> actor
deblasis Dec 14, 2022
14e8d48
refactor(P2P): moar validator -> actor
deblasis Dec 14, 2022
70b7a75
fix(P2P): validator -> actor
deblasis Dec 14, 2022
628b960
Merge branch 'issue/270-p2p-integration-with-utility-for-addrbook-loo…
deblasis Dec 14, 2022
7b0eb8c
refactor(Shared): ValidatorMap() ConsensusModule iface no more
deblasis Dec 15, 2022
92c6050
refactor(P2P): addrBookProvider cleanup
deblasis Dec 15, 2022
30c18c5
refactor(Consensus): removed ValidatorMapToModulesValidatorMap
deblasis Dec 15, 2022
4f43b5d
refactor(P2P): updated to source addresses via persistence only
deblasis Dec 15, 2022
b62365a
fix(P2P): fixed tests after ValidatorMap removal
deblasis Dec 15, 2022
0f18c5b
test(P2P): updated mocks
deblasis Dec 15, 2022
b41f5b1
refactor(P2P): updated AddrBookProvider
deblasis Dec 15, 2022
3131e00
docs(Persistence): updated TODO
deblasis Dec 15, 2022
8954e86
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 15, 2022
9735b50
Merge branch 'issue/270-p2p-integration-with-utility-for-addrbook-loo…
deblasis Dec 15, 2022
b5f2ef5
Update p2p/addrbook_provider/persistence.go
deblasis Dec 15, 2022
9eb0646
refactor(P2P): renamed mockDummyBus to mockBus
deblasis Dec 15, 2022
4e3d227
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 15, 2022
6d9e45c
Merge branch 'issue/270-p2p-integration-with-utility-for-addrbook-loo…
deblasis Dec 15, 2022
5899337
docs(Consensus): CHANGELOG
deblasis Dec 15, 2022
ac11ed1
docs(Shared): CHANGELOGs
deblasis Dec 15, 2022
abcc7cd
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 15, 2022
9a32d51
fix(P2P): changelog missing
deblasis Dec 15, 2022
96d00fa
Merge branch 'issue/271-p2p-persistence-addrbook-management_l' into i…
deblasis Dec 15, 2022
a00761e
Merge branch 'issue/270-p2p-integration-with-utility-for-addrbook-loo…
deblasis Dec 15, 2022
c7ac954
Merge remote-tracking branch 'upstream/main' into issue/203-validatorMap
deblasis Dec 16, 2022
e5fd2ad
fix(P2P): removed getter
deblasis Dec 16, 2022
185b429
chore(Consensus): typo
deblasis Dec 16, 2022
bc8d8ae
chore(shared): nits
deblasis Dec 21, 2022
bd25a73
refactor(CLI): hardcoded addressbook
deblasis Dec 22, 2022
843f1b4
feat(P2P): providers for addressbook and currentheight
deblasis Dec 22, 2022
fe3418b
fix(build): updated configs with missing value
deblasis Dec 22, 2022
eff0afb
feat(P2P): updated raintree to use the providers
deblasis Dec 22, 2022
a4ea7df
feat(CLI): updated to spin up only P2P
deblasis Dec 22, 2022
2eea763
refactor(P2P): updated stdnetwork to use providers
deblasis Dec 22, 2022
77586e4
feat(P2P): isClientOnly flag
deblasis Dec 22, 2022
7b3b7c5
refactor(P2P): injected providers
deblasis Dec 22, 2022
6213789
chore(go.mod): tidy
deblasis Dec 22, 2022
3c026f7
feat(Makefile): flag override for isClientOnly
deblasis Dec 22, 2022
c9b27ee
fix(P2P): stdnetwork uses currentHeightProvider as well
deblasis Dec 22, 2022
5e01b23
Merge remote-tracking branch 'upstream/main' into issue/203-validatorMap
deblasis Dec 22, 2022
ec59138
docs(P2P): changelog
deblasis Dec 22, 2022
981da2c
docs(shared): changelog
deblasis Dec 22, 2022
cc221b6
docs(consensus): changelog
deblasis Dec 22, 2022
4a820dc
docs(CLI): changelog
deblasis Dec 22, 2022
2abd96b
docs(build): changelog
deblasis Dec 22, 2022
9efa129
fix(build): changelog...
deblasis Dec 22, 2022
21f182d
fix(CLI): changelog
deblasis Dec 22, 2022
7972285
fix(P2P): addrbook_provider
deblasis Dec 28, 2022
fc2a042
docs(P2P): CHANGELOG
deblasis Dec 29, 2022
46d6fb1
docs(shared): CHANGELOGs dates update...
deblasis Dec 29, 2022
59847fa
test(P2P): fixed tests, added missing expected call to Close
deblasis Dec 29, 2022
9a6d9ea
Merge remote-tracking branch 'upstream/main' into issue/203-validatorMap
deblasis Jan 4, 2023
3eeef0d
chore(shared): merge fixes
deblasis Jan 4, 2023
0445cdb
Merge remote-tracking branch 'upstream/main' into issue/203-validatorMap
deblasis Jan 4, 2023
bd9fc6b
docs(shared): CHANGELOG
deblasis Jan 4, 2023
2b8016c
refactor(CLI): simplified init
deblasis Jan 4, 2023
d54634c
docs(CLI): comments + changelog
deblasis Jan 4, 2023
8a42941
docs(CLI): clarification
deblasis Jan 4, 2023
79d668c
Update app/client/cli/doc/CHANGELOG.md
deblasis Jan 4, 2023
3d3d0b3
docs(CLI): todo link
deblasis Jan 4, 2023
7c819d8
Merge branch 'issue/203-validatorMap' of github.com:pokt-network/pock…
deblasis Jan 4, 2023
b32e865
Update app/client/cli/debug.go
deblasis Jan 4, 2023
ef5c8b9
Update build/docs/CHANGELOG.md
deblasis Jan 4, 2023
cd1ff15
Update build/docs/CHANGELOG.md
deblasis Jan 4, 2023
f33fa30
refactor(addrbook_provider): ALL_HEIGHTS
deblasis Jan 4, 2023
4f06f56
Update app/client/cli/doc/CHANGELOG.md
deblasis Jan 4, 2023
a1cba4f
Merge branch 'issue/203-validatorMap' of github.com:pokt-network/pock…
deblasis Jan 4, 2023
307c137
Update runtime/configs/proto/p2p_config.proto
deblasis Jan 4, 2023
9d0c61b
Update p2p/raintree/network.go
deblasis Jan 9, 2023
d7b9577
refactor(P2P): provider.go
deblasis Jan 9, 2023
2e1dccb
refactor(P2P): addrbook_provider
deblasis Jan 9, 2023
c9e1940
Update p2p/providers/addrbook_provider/addrbook_provider.go
deblasis Jan 9, 2023
4ca994b
Merge branch 'issue/203-validatorMap' of github.com:pokt-network/pock…
deblasis Jan 9, 2023
c76a391
docs(P2P): marking todo #429
deblasis Jan 9, 2023
343dea3
refactor(P2P): current_height_provider.go -> provider.go
deblasis Jan 9, 2023
90d331d
docs(P2P): cleanup (#429)
deblasis Jan 9, 2023
baa3aab
fix(P2P): fixed (*debugAddrBookProvider) getActorsByHeight
deblasis Jan 9, 2023
69d060c
chore(P2P): 🧹
deblasis Jan 9, 2023
01a609b
feat(P2P): debug addrbook_provider log on ANY_HEIGHT
deblasis Jan 9, 2023
185b524
docs(shared): CHANGELOGs
deblasis Jan 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.

What if we just rename POCKET_P2P_IS_CLIENT_ONLY to CLIENT_DEBUG_MODE to capture this, and potentially other needs in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to leverage viper it has to start with POCKET_P2P so how about POCKET_P2P_CLIENT_DEBUG_MODE ?

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

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

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 have tackled this in the other PR here d313d97 because the implementation was just easier there (due to the improvements to module initialization) and doing it here would have required some extra work that than I would have had to refactor anyway.


.PHONY: build_and_watch
build_and_watch: ## Continous build Pocket's main entrypoint as files change
Expand Down Expand Up @@ -224,11 +224,11 @@ mockgen: clean_mocks ## Use `mockgen` to generate mocks used for testing purpose
go generate ./${modules_dir}
echo "Mocks generated in ${modules_dir}/mocks"

$(eval p2p_types_dir = "p2p/types")
$(eval p2p_dir = "p2p")
$(eval p2p_type_mocks_dir = "p2p/types/mocks")
find ${p2p_type_mocks_dir} -type f ! -name "mocks.go" -exec rm {} \;
go generate ./${p2p_types_dir}
echo "P2P mocks generated in ${p2p_types_dir}/mocks"
go generate ./${p2p_dir}/...
echo "P2P mocks generated in ${p2p_type_mocks_dir}"

# TODO(team): Tested locally with `protoc` version `libprotoc 3.19.4`. In the near future, only the Dockerfiles will be used to compile protos.

Expand Down
109 changes: 42 additions & 67 deletions app/client/cli/debug.go
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
//go:build debug
// +build debug

package cli

import (
"log"
"os"
"sync"

"github.com/manifoldco/promptui"
"github.com/pokt-network/pocket/consensus"
"github.com/pokt-network/pocket/logger"
"github.com/pokt-network/pocket/p2p"
"github.com/pokt-network/pocket/rpc"
debugABP "github.com/pokt-network/pocket/p2p/providers/addrbook_provider/debug"
debugCHP "github.com/pokt-network/pocket/p2p/providers/current_height_provider/debug"
"github.com/pokt-network/pocket/runtime"
"github.com/pokt-network/pocket/shared"
coreTypes "github.com/pokt-network/pocket/shared/core/types"
pocketCrypto "github.com/pokt-network/pocket/shared/crypto"
"github.com/pokt-network/pocket/shared/messaging"
"github.com/pokt-network/pocket/shared/modules"
"github.com/pokt-network/pocket/telemetry"
"github.com/spf13/cobra"
"google.golang.org/protobuf/types/known/anypb"
)
Expand All @@ -39,17 +33,18 @@ var (
// A P2P module is initialized in order to broadcast a message to the local network
p2pMod modules.P2PModule

// A consensus module is initialized in order to get a list of the validator network
consensusMod modules.ConsensusModule
modInitOnce sync.Once

items = []string{
PromptResetToGenesis,
PromptPrintNodeState,
PromptTriggerNextView,
PromptTogglePacemakerMode,
PromptShowLatestBlockInStore,
}

// validators holds the list of the validators at genesis time so that we can use it to create a debug address book provider.
// Its purpose is to allow the CLI to "discover" the nodes in the network. Since currently we don't have churn and we run nodes only in LocalNet, we can rely on the genesis state.
// HACK(#416): This is a temporary solution that guarantees backward compatibility while we implement peer discovery
validators []*coreTypes.Actor
deblasis marked this conversation as resolved.
Show resolved Hide resolved
)

func init() {
Expand All @@ -62,7 +57,30 @@ func NewDebugCommand() *cobra.Command {
Short: "Debug utility for rapid development",
Args: cobra.ExactArgs(0),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
initDebug(remoteCLIURL)
var err error
runtimeMgr := runtime.NewManagerFromFiles(defaultConfigPath, defaultGenesisPath, runtime.WithRandomPK())

// HACK(#416): this is a temporary solution that guarantees backward compatibility while we implement peer discovery.
validators = runtimeMgr.GetGenesis().Validators

debugAddressBookProvider := debugABP.NewDebugAddrBookProvider(
runtimeMgr.GetConfig().P2P,
debugABP.WithActorsByHeight(
map[int64][]*coreTypes.Actor{
debugABP.ANY_HEIGHT: validators,
},
),
)

debugCurrentHeightProvider := debugCHP.NewDebugCurrentHeightProvider(0)

p2pM, err := p2p.CreateWithProviders(runtimeMgr, debugAddressBookProvider, debugCurrentHeightProvider)
if err != nil {
log.Fatalf("[ERROR] Failed to create p2p module: %v", err.Error())
}
p2pMod = p2pM.(modules.P2PModule)

p2pMod.Start()
},
RunE: runDebug,
}
Expand Down Expand Up @@ -148,8 +166,8 @@ func broadcastDebugMessage(debugMsg *messaging.DebugMessage) {
// address book of the actual validator nodes, so `node1.consensus` never receives the message.
// p2pMod.Broadcast(anyProto, messaging.PocketTopic_DEBUG_TOPIC)

for _, val := range consensusMod.ValidatorMap() {
addr, err := pocketCrypto.NewAddress(val.GetAddress())
for _, valAddr := range validators {
addr, err := pocketCrypto.NewAddress(valAddr.GetAddress())
if err != nil {
log.Fatalf("[ERROR] Failed to convert validator address into pocketCrypto.Address: %v", err)
}
Expand All @@ -165,58 +183,15 @@ func sendDebugMessage(debugMsg *messaging.DebugMessage) {
}

var validatorAddress []byte
for _, val := range consensusMod.ValidatorMap() {
validatorAddress, err = pocketCrypto.NewAddress(val.GetAddress())
if err != nil {
log.Fatalf("[ERROR] Failed to convert validator address into pocketCrypto.Address: %v", err)
}
break
if len(validators) == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Rather than throwing a fatal error on every debug message, let's do this and the point of initialization in initDebug.

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 disagree, at some point, hopefully VERY soon, we'll have dynamic node set and we could (also for testing purposes) just don't have any addressable node to connect to when we send.

I would keep the guard here so that whoever touches this code is aware of that eventuality at runtime.
I wouldn't even bother adding a check in initDebug because for now it's straight from genesis and it doesn't change.

log.Fatalf("[ERROR] No validators found")
}

p2pMod.Send(validatorAddress, anyProto)
}

func initDebug(remoteCLIURL string) {
modInitOnce.Do(func() {
var err error
runtimeMgr := runtime.NewManagerFromFiles(defaultConfigPath, defaultGenesisPath, runtime.WithRandomPK())

consM, err := consensus.Create(runtimeMgr)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create consensus module")
}
consensusMod = consM.(modules.ConsensusModule)

p2pM, err := p2p.Create(runtimeMgr)
if err != nil {
log.Fatalf("[ERROR] Failed to create p2p module: %v", err.Error())
}
p2pMod = p2pM.(modules.P2PModule)

// This telemetry module instance is a NOOP because the 'enable_telemetry' flag in the `cfg` above is set to false.
// Since this client mimics partial - networking only - functionality of a full node, some of the telemetry-related
// code paths are executed. To avoid those messages interfering with the telemetry data collected, a non-nil telemetry
// module that NOOPs (per the configs above) is injected.
telemetryM, err := telemetry.Create(runtimeMgr)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create telemetry module")
}
telemetryMod := telemetryM.(modules.TelemetryModule)

loggerM, err := logger.Create(runtimeMgr)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create logger module")
}
loggerMod := loggerM.(modules.LoggerModule)

rpcM, err := rpc.Create(runtimeMgr)
if err != nil {
logger.Global.Fatal().Err(err).Msg("Failed to create rpc module")
}
rpcMod := rpcM.(modules.RPCModule)

_ = shared.CreateBusWithOptionalModules(runtimeMgr, nil, p2pMod, nil, consensusMod, telemetryMod, loggerMod, rpcMod) // REFACTOR: use the `WithXXXModule()` pattern accepting a slice of IntegratableModule
// if the message needs to be broadcast, it'll be handled by the business logic of the message handler
validatorAddress, err = pocketCrypto.NewAddress(validators[0].GetAddress())
deblasis marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
log.Fatalf("[ERROR] Failed to convert validator address into pocketCrypto.Address: %v", err)
}

p2pMod.Start()
})
p2pMod.Send(validatorAddress, anyProto)
}
6 changes: 6 additions & 0 deletions app/client/cli/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.4] - 2023-01-09

- The `client` (i.e. CLI) no longer instantiates a `P2P` module along with a bus of optional modules. Instead, it instantiates a `client-only` `P2P` module that is disconnected from consensus and persistence. Interactions with the persistence & consensus layer happen via RPC.
- Replaced previous implementation, reliant on `ValidatorMap`, with a temporary fetch from genesis. This will be replaced with a lightweight peer discovery mechanism in #416
- Simplified debug CLI initialization

## [0.0.0.3] - 2023-01-03

- Updated to use `coreTypes` instead of utility types for `Actor` and `ActorType`
Expand Down
4 changes: 3 additions & 1 deletion build/config/config1.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4"
"private_key": "6fd0bc54cc2dd205eaf226eebdb0451629b321f11d279013ce6fdd5a33059256b2eda2232ffb2750bf761141f70f75a03a025f65b2b2b417c7f8b3c9ca91e8e4",
"max_mempool_count": 100000,
"is_client_only": false
},
"telemetry": {
"enabled": true,
Expand Down
3 changes: 2 additions & 1 deletion build/config/config2.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "5db3e9d97d04d6d70359de924bb02039c602080d6bf01a692bad31ad5ef93524c16043323c83ffd901a8bf7d73543814b8655aa4695f7bfb49d01926fc161cdb"
"private_key": "5db3e9d97d04d6d70359de924bb02039c602080d6bf01a692bad31ad5ef93524c16043323c83ffd901a8bf7d73543814b8655aa4695f7bfb49d01926fc161cdb",
"max_mempool_count": 100000
},
"telemetry": {
"enabled": true,
Expand Down
3 changes: 2 additions & 1 deletion build/config/config3.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2"
"private_key": "b37d3ba2f232060c41ba1177fea6008d885fcccad6826d64ee7d49f94d1dbc49a8b6be75d7551da093f788f7286c3a9cb885cfc8e52710eac5f1d5e5b4bf19b2",
"max_mempool_count": 100000
},
"telemetry": {
"enabled": true,
Expand Down
3 changes: 2 additions & 1 deletion build/config/config4.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"consensus_port": 8080,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a"
"private_key": "c6c136d010d07d7f5e9944aa3594a10f9210dd3e26ebc1bc1516a6d957fd0df353ee26c82826694ffe1773d7b60d5f20dd9e91bdf8745544711bec5ff9c6fb4a",
"max_mempool_count": 100000
},
"telemetry": {
"enabled": true,
Expand Down
7 changes: 6 additions & 1 deletion build/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.1] - 2023-01-03
## [0.0.0.2] - 2023-01-09

- Removed `BaseConfig` from `configs`
- Centralized `PersistenceGenesisState` and `ConsensusGenesisState` into `GenesisState`

## [0.0.0.1] - 2022-12-29

- Updated all `config*.json` files with the missing `max_mempool_count` value
- Added `is_client_only` to `config1.json` so Viper knows it can be overridden. The config override is done in the Makefile's `client_connect` target. Setting this can be avoided if we merge the changes in https://github.com/pokt-network/pocket/compare/main...issue/cli-viper-environment-vars-fix

Olshansk marked this conversation as resolved.
Show resolved Hide resolved
## [0.0.0.0] - 2022-12-22

- Introduced this `CHANGELOG.md`
3 changes: 2 additions & 1 deletion consensus/doc/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.16] - 2023-01-03
## [0.0.0.16] - 2023-01-09

- Added protobuf message definitions for requests related to sharing state sync metadata and blocks
- Defined the interface for `StateSyncServerModule`, `StateSyncModule` (moving the old interface to `StateSyncModuleLEGACY` as a reference only)
- Overhaul (updates, improvements, clarifications & additions) of the State Sync README
- Removed `ValidatorMap() ValidatorMap`

## [0.0.0.15] - 2023-01-03

Expand Down
4 changes: 0 additions & 4 deletions consensus/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ func (m *consensusModule) CurrentStep() uint64 {
return uint64(m.step)
}

func (m *consensusModule) ValidatorMap() modules.ValidatorMap { // TODO: This needs to be dynamically updated during various operations and network changes.
return typesCons.ValidatorMapToModulesValidatorMap(m.validatorMap)
}

// TODO: Populate the entire state from the persistence module: validator set, quorum cert, last block hash, etc...
func (m *consensusModule) loadPersistedState() error {
persistenceContext, err := m.GetBus().GetPersistenceModule().NewReadContext(-1) // Unknown height
Expand Down
9 changes: 0 additions & 9 deletions consensus/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"sort"

coreTypes "github.com/pokt-network/pocket/shared/core/types"
"github.com/pokt-network/pocket/shared/modules"
)

type NodeId uint64
Expand Down Expand Up @@ -42,14 +41,6 @@ func GetValAddrToIdMap(validatorMap ValidatorMap) (ValAddrToIdMap, IdToValAddrMa
return valToIdMap, idToValMap
}

func ValidatorMapToModulesValidatorMap(validatorMap ValidatorMap) (vm modules.ValidatorMap) {
vm = make(modules.ValidatorMap)
for _, v := range validatorMap {
vm[v.GetAddress()] = *v
}
return
}

func ActorListToValidatorMap(actors []*coreTypes.Actor) (m ValidatorMap) {
m = make(ValidatorMap, len(actors))
for _, a := range actors {
Expand Down
12 changes: 12 additions & 0 deletions p2p/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.0.0.16] - 2023-01-09

- Added missing `Close()` call to `persistenceReadContext`

## [0.0.0.15] - 2023-01-03

- Refactored `AddrBookProvider` to support multiple implementations
- Added `CurrentHeightProvider`
- Dependency injection of the aforementioned provider into the module creation (used by the debug-client)
- Updated implementation to use the providers
- Updated tests and mocks

## [0.0.0.14] - 2023-01-03

- `ActorsToAddrBook` now skips actors that are not validators since they don't have a serviceUrl generic parameter
Expand Down
19 changes: 0 additions & 19 deletions p2p/addrbook_provider/getter.go

This file was deleted.

Loading