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

feat: autodetect NodeID in ValdatorUpdate (TD-40) #213

Merged
merged 14 commits into from
Jan 4, 2022

Conversation

lklimek
Copy link
Collaborator

@lklimek lklimek commented Nov 10, 2021

Issue being fixed or feature implemented

In #187 , we require ABCI app to provide Node ID as part of validator address. But ABCI app doesn’t have it. We need to determine it inside Tenderdash if not provided.

What was done?

  1. Implemented ValidatorAddress that is just like p2p.NodeAddress, but doesn't require NodeID
  2. Implemented method to determine node ID based on hostname+port, by downloading remote public key and deriving node id from it. This method is only called when needed due to its cost (eg. only for validators to which we connect, which is logarithm of the number of active validators
  3. Using proTxHash to index validator maps inside dash/quorum package

How Has This Been Tested?

  1. E2E tests with manual verification

Breaking Changes

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@codecov-commenter
Copy link

codecov-commenter commented Nov 15, 2021

Codecov Report

Merging #213 (d5fc0e0) into TD-30-dedicated-slots (706c079) will increase coverage by 0.03%.
The diff coverage is 57.30%.

Impacted file tree graph

@@                    Coverage Diff                    @@
##           TD-30-dedicated-slots     #213      +/-   ##
=========================================================
+ Coverage                  45.21%   45.25%   +0.03%     
=========================================================
  Files                        286      288       +2     
  Lines                      52793    52896     +103     
=========================================================
+ Hits                       23872    23938      +66     
- Misses                     26964    26993      +29     
- Partials                    1957     1965       +8     
Impacted Files Coverage Δ
abci/types/types.pb.go 3.07% <ø> (ø)
privval/dash_core_signer_client.go 0.00% <0.00%> (ø)
types/validator_set.go 63.64% <0.00%> (ø)
p2p/address.go 21.60% <36.36%> (+2.55%) ⬆️
dash/types/validator_address.go 41.50% <41.50%> (ø)
types/validator.go 66.06% <52.94%> (+1.24%) ⬆️
dash/types/nodeid_resolver.go 64.51% <64.51%> (ø)
p2p/conn/secret_connection.go 82.94% <73.91%> (-0.68%) ⬇️
dash/quorum/validator_conn_executor.go 68.52% <78.57%> (+0.97%) ⬆️
abci/example/kvstore/helpers.go 90.90% <100.00%> (ø)
... and 22 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 706c079...d5fc0e0. Read the comment docs.

@lklimek lklimek force-pushed the TD-40-empty-node-id branch 2 times, most recently from 6e787d6 to 0ce2c02 Compare November 17, 2021 17:21
Copy link
Collaborator

@shotonoff shotonoff left a comment

Choose a reason for hiding this comment

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

Good job 🚀
please have a look at the comments to the PR

dash/dashtypes/validator_address.go Outdated Show resolved Hide resolved
dash/dashtypes/validator_address.go Outdated Show resolved Hide resolved
dash/dashtypes/validator_address.go Outdated Show resolved Hide resolved
panic(fmt.Sprintf("cannot generate random validator address: %s", err))
}
if err := addr.Validate(); err != nil {
panic(fmt.Sprintf("randomly generated validator address %s is invalid: %s", addr.String(), err))
Copy link
Collaborator

Choose a reason for hiding this comment

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

here as well

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

RandValidatorAddress() is only used in tests. Changing it to return err makes it much harder. Besides, these error conditions should never happen.

dash/dashtypes/validator_address.go Outdated Show resolved Hide resolved
dash/dashtypes/validator_address.go Outdated Show resolved Hide resolved
dash/dashtypes/validator_address_test.go Outdated Show resolved Hide resolved
dash/dashtypes/validator_address_test.go Outdated Show resolved Hide resolved
dash/quorum/validator_conn_executor.go Outdated Show resolved Hide resolved
dash/quorum/validator_conn_executor.go Outdated Show resolved Hide resolved
@lklimek lklimek self-assigned this Dec 2, 2021
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Dec 20, 2021
@lklimek lklimek removed the Stale label Dec 20, 2021
@lklimek
Copy link
Collaborator Author

lklimek commented Dec 20, 2021

waiting for integration testing

@lklimek lklimek marked this pull request as ready for review December 21, 2021 09:04
@lklimek lklimek added this to the 0.7.0 milestone Dec 21, 2021
@github-actions
Copy link

github-actions bot commented Jan 1, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@github-actions github-actions bot added the Stale label Jan 1, 2022
@lklimek lklimek changed the title feat: autodetect NodeID in ValdatorUpdate feat: autodetect NodeID in ValdatorUpdate (TD-40) Jan 4, 2022
Convert validators map to string before logging. Without this
change, elasticsearch maps each validator as a separate field,
like:
`json.validators.1AD56AAACE6385A240B3A85EC231ACDE3972CD21A09678A7924B28116314A29C.address.Hostname`
@lklimek lklimek merged commit 91958a1 into TD-30-dedicated-slots Jan 4, 2022
@lklimek lklimek deleted the TD-40-empty-node-id branch January 4, 2022 14:17
lklimek added a commit that referenced this pull request Jan 7, 2022
This commit adds the capability to establish direct communication between multiple validators that are members of the same validator set. See [ADR D001](https://github.com/dashevo/tenderdash/blob/bb69b12ef3fb45a38e85e05662bd93f907f153fc/docs/architecture/adr-d001-inter-validator-set-messaging.md) for more details.

* feat: Add address to ABCI ValidatorUpdate message

* feat:ipaddress parsing logic added

* refactor: reorganize protobuf dependency tree

* test: ipaddress unit tests added + some fixes

* refactor: avoid large changes in *.proto to make backporting easier

* refactor: move lines around to avoid future conflicts

* refactor: format .proto files using `make proto-format`

* refactor: use factory pattern for IPAddress

* doc: fix comment of IPAddress.MustParseIP

* refactor: iptables.Copy() improvements

* refactor: move mustParseIP() to ipaddress_test.go

* refactor: use String URI for validator address

* feat: update code to work with abci.ValidatorUpdate.Address

* test: updated tests to support abci ValidatorUpdate.Address

* test: validator update address - unit tests green

* refactor: add ValidatorAddress type

* e2e/tests: fix validator address test

* refactor: make linter happy

* dash:  validator connection executor, WIP

* feat: Add address to ABCI ValidatorUpdate message

* feat:ipaddress parsing logic added

* refactor: reorganize protobuf dependency tree

* test: ipaddress unit tests added + some fixes

* refactor: avoid large changes in *.proto to make backporting easier

* refactor: move lines around to avoid future conflicts

* refactor: format .proto files using `make proto-format`

* refactor: use factory pattern for IPAddress

* doc: fix comment of IPAddress.MustParseIP

* refactor: iptables.Copy() improvements

* refactor: move mustParseIP() to ipaddress_test.go

* refactor: use String URI for validator address

* feat: update code to work with abci.ValidatorUpdate.Address

* test: updated tests to support abci ValidatorUpdate.Address

* test: validator update address - unit tests green

* refactor: add ValidatorAddress type

* e2e/tests: fix validator address test

* refactor: make linter happy

* refactor: rename file with ValidatorConnExecutor

* feat:inter validator set - work in progress

* e2e: enable p2p_debug and add more validator updates

* feat: inter validator set messaging

* test: inter validator set communication

* doc: update adr-d001 to reflect current implementation

* p2p: test TestTransportHandshake - wait for server to start

* refactor: code cleanup of inter validator set

* refactor: replace types.ValidatorAddress with p2p.NodeAddress

* p2p: allow empty validator address

* state: remove unused code

* test(p2p): TestTransportHandshake - add some sync

* test: improve TestValidatorConnExecutor tests

* refactor: rneame validator(update).Address to NodeAddress

* typo: fix linter issue

* refactor: apply code review feedback (WIP)

* refactor(dash): apply code review feedback, continued

* refactor(dash): improve validatorMap

* state: Add QuorumHash to EventValidatorSetUpdates

* feat: select validators to connect directly according to DIP-6 (WIP)

* fix: fix rebase conflicts

* feat: algorithm to select validators according to DIP-6

* refactor: rename select_nodes.go to select_validators.go

* feat: Use DIP-6 to select Validators for inter-validator set comm

* dash: add some code comments

* refactor: move files to separate packages

* test: fix e2e tests for single and simple networks

Validators in validator set contain address only after first
quorum rotation.

* refactor: apply code review feedback

* refactor: store validator as value (not pointer) internally

* refactor: change package names in dash/

* refactor(selectpeers): rename SelectValidatorsDIP6 to DIP6

* refactor: minor code formatting fixes

* refactor: Apply suggestions from code review

Co-authored-by: Dmitrii Golubev <dmitrii.golubev@deliveryhero.com>

* refactor: minor code improvements

* refactor: minor code improvements

* test: revert handshake timeout

* refactor: apply peer review feedback

* refactor: fix comment

Co-authored-by: Dmitrii Golubev <dmitrii.golubev@deliveryhero.com>

* doc(adr-d001): update ValidatorUpdate struct

* fix(selectpeers): add fallback for less than 5 validators

* refactor(selectpeers): Add ValidatorSelector interface

* test(p2p): tune sleep time when waiting for port to get opened

* feat: use validators from init chain response or genesis to establish connection (#228)

* feat: use validator list from init-chain response or genesis file to establish connection with them in inter-validator component

* refactor: move the logger from required argument into optional parameter, by defailt is used NopLogger

* fix: check a size of persisted peers before deleting

* feat: add "island" manifest file where every validator is isolated from each other

* feat: add a task into Makefile to run "island" e2e test

* chore: remove debug logging

* feat: autodetect NodeID in ValdatorUpdate (TD-40) (#213)

* feat: autodetect NodeID in ValdatorUpdate

* feat(dash/quorum): handle validators without address

* feat(quorum): Autodetect node ID when connecting to quorum members

* test(p2p/conn): remove unused privKeyWithNilPubKey

* doc(adr-d001): inter-validator set node id lookup

* refactor(quorum): apply code review feedback

* refactor(dash/types): rename package dashtypes to types

* refactor(p2p): make ValidateID exportable

* test(dash/types): increase validator address test coverage

* test(e2e): no node id in validator update address

* fix: node id not retrieved when processing val updates

* feat(dash/quorum): lookup node id in address book

* fix(dash/quorum): log validators list as single string

Convert validators map to string before logging. Without this
change, elasticsearch maps each validator as a separate field,
like:
`json.validators.1AD56AAACE6385A240B3A85EC231ACDE3972CD21A09678A7924B28116314A29C.address.Hostname`

* refactor: code comments, improved strings

* doc(adr-d001): update doc after implementation

* doc(adr-d001): apply feedback

Co-authored-by: shotonoff <shotonoff@gmail.com>
lklimek added a commit that referenced this pull request Feb 15, 2022
* feat: improve logging for better elasticsearch compatibility (#220)

Unified logging of height and round, fixed some bugs:

* consensus: improve logging of vote messages to get better reporting

* fix(pex): use Logger instead of Printf

This fixes issues with parsing of logs for elastic

* fix(scripts): consensus.CommitMessage not defined in wal2json

* refactor(consensus,log): Unify logging of object metadata

* fix(types): invalid vote sign bytes put into error msg

* refactor(p2p): log ping-pong on P2PDebug level

* refactor(log): revert addition of LogableObject

* refactor(consensus): apply code review feedback

* fix: fix the most of the compile errors

* chore: update import section

* feat(abci): InitChain can set initial core lock height (#222)

* feat(consensus): InitChain can set initial core height

* test(consensus): initial core height unit test

* test(e2e): allow setting of core height in resp to InitApp

* refactor(e2e): unify cfg name init_app_core_chain_locked_height

* test(consensus): remove not needed InitChain response

* fix(consensus): fix last core chain lock detection tests

* refactor(abci): remove last_core_chain_locked_height from ResponseInfo

* refactor(statesync): fix lint warnings

* feat(maverick): support initial core height from InitChain

* test(e2e): revert chainlock update height to 1000 in rotate.toml

* fix: regenerate remote_client.go mock, some fixes by feedback

* fix: remove unused global variables

* build(deps): bump github.com/rs/cors from 1.8.0 to 1.8.2

Bumps [github.com/rs/cors](https://github.com/rs/cors) from 1.8.0 to 1.8.2.
- [Release notes](https://github.com/rs/cors/releases)
- [Commits](rs/cors@v1.8.0...v1.8.2)

---
updated-dependencies:
- dependency-name: github.com/rs/cors
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* fix: some fixes for 0.35 backport

* fix: some fixes for 0.35 backport

* feat(consensus): add empty block on h-1 and h-2 apphash change (#241)

* feat(consensus): add empty block on h-1 and h-2 apphash change

Before this change, empty block was created when apphash was changed since previous (height-1) block. This change changes this behavior to also check block (height-2).

* test(consensus): empty block on h-1 and h-2 apphash change

* rebase(consensus): apply code review feedback

* fix(evidence): fix all failed tests in evidence package

* fix(store): fix unit tests for internal/store package

* fix(blocksync): fix unit tests for internal/blocksync package

* fix(p2p): remove redundant sleep from TestMConnTransport_Listen

* fix(blocksync): fic blocksync/v2 test

* fix(rpc): allow reading "request_quorum_info" param for rpc "validators" handler

* fix(state): fix internal/state package

* fix(state): fix internal/statesync package

* fix(test): fix internal/test/factory package

* fix(privval): some fixes for unit tests

* fix(privval): fix tests TestPrivvalVectors, TestStateSyncVectors

* fix(consensus): fix consensus logic and tests

* fix: remove generating AppHash from genesis

* fix: remove debug printing

* fix(mempool): fix TestSerialReap

* fix(rpc): fix TestBroadcastEvidence_DuplicateVoteEvidence

* feat: inter-validator set communication (#187)

This commit adds the capability to establish direct communication between multiple validators that are members of the same validator set. See [ADR D001](https://github.com/dashevo/tenderdash/blob/bb69b12ef3fb45a38e85e05662bd93f907f153fc/docs/architecture/adr-d001-inter-validator-set-messaging.md) for more details.

* feat: Add address to ABCI ValidatorUpdate message

* feat:ipaddress parsing logic added

* refactor: reorganize protobuf dependency tree

* test: ipaddress unit tests added + some fixes

* refactor: avoid large changes in *.proto to make backporting easier

* refactor: move lines around to avoid future conflicts

* refactor: format .proto files using `make proto-format`

* refactor: use factory pattern for IPAddress

* doc: fix comment of IPAddress.MustParseIP

* refactor: iptables.Copy() improvements

* refactor: move mustParseIP() to ipaddress_test.go

* refactor: use String URI for validator address

* feat: update code to work with abci.ValidatorUpdate.Address

* test: updated tests to support abci ValidatorUpdate.Address

* test: validator update address - unit tests green

* refactor: add ValidatorAddress type

* e2e/tests: fix validator address test

* refactor: make linter happy

* dash:  validator connection executor, WIP

* feat: Add address to ABCI ValidatorUpdate message

* feat:ipaddress parsing logic added

* refactor: reorganize protobuf dependency tree

* test: ipaddress unit tests added + some fixes

* refactor: avoid large changes in *.proto to make backporting easier

* refactor: move lines around to avoid future conflicts

* refactor: format .proto files using `make proto-format`

* refactor: use factory pattern for IPAddress

* doc: fix comment of IPAddress.MustParseIP

* refactor: iptables.Copy() improvements

* refactor: move mustParseIP() to ipaddress_test.go

* refactor: use String URI for validator address

* feat: update code to work with abci.ValidatorUpdate.Address

* test: updated tests to support abci ValidatorUpdate.Address

* test: validator update address - unit tests green

* refactor: add ValidatorAddress type

* e2e/tests: fix validator address test

* refactor: make linter happy

* refactor: rename file with ValidatorConnExecutor

* feat:inter validator set - work in progress

* e2e: enable p2p_debug and add more validator updates

* feat: inter validator set messaging

* test: inter validator set communication

* doc: update adr-d001 to reflect current implementation

* p2p: test TestTransportHandshake - wait for server to start

* refactor: code cleanup of inter validator set

* refactor: replace types.ValidatorAddress with p2p.NodeAddress

* p2p: allow empty validator address

* state: remove unused code

* test(p2p): TestTransportHandshake - add some sync

* test: improve TestValidatorConnExecutor tests

* refactor: rneame validator(update).Address to NodeAddress

* typo: fix linter issue

* refactor: apply code review feedback (WIP)

* refactor(dash): apply code review feedback, continued

* refactor(dash): improve validatorMap

* state: Add QuorumHash to EventValidatorSetUpdates

* feat: select validators to connect directly according to DIP-6 (WIP)

* fix: fix rebase conflicts

* feat: algorithm to select validators according to DIP-6

* refactor: rename select_nodes.go to select_validators.go

* feat: Use DIP-6 to select Validators for inter-validator set comm

* dash: add some code comments

* refactor: move files to separate packages

* test: fix e2e tests for single and simple networks

Validators in validator set contain address only after first
quorum rotation.

* refactor: apply code review feedback

* refactor: store validator as value (not pointer) internally

* refactor: change package names in dash/

* refactor(selectpeers): rename SelectValidatorsDIP6 to DIP6

* refactor: minor code formatting fixes

* refactor: Apply suggestions from code review

Co-authored-by: Dmitrii Golubev <dmitrii.golubev@deliveryhero.com>

* refactor: minor code improvements

* refactor: minor code improvements

* test: revert handshake timeout

* refactor: apply peer review feedback

* refactor: fix comment

Co-authored-by: Dmitrii Golubev <dmitrii.golubev@deliveryhero.com>

* doc(adr-d001): update ValidatorUpdate struct

* fix(selectpeers): add fallback for less than 5 validators

* refactor(selectpeers): Add ValidatorSelector interface

* test(p2p): tune sleep time when waiting for port to get opened

* feat: use validators from init chain response or genesis to establish connection (#228)

* feat: use validator list from init-chain response or genesis file to establish connection with them in inter-validator component

* refactor: move the logger from required argument into optional parameter, by defailt is used NopLogger

* fix: check a size of persisted peers before deleting

* feat: add "island" manifest file where every validator is isolated from each other

* feat: add a task into Makefile to run "island" e2e test

* chore: remove debug logging

* feat: autodetect NodeID in ValdatorUpdate (TD-40) (#213)

* feat: autodetect NodeID in ValdatorUpdate

* feat(dash/quorum): handle validators without address

* feat(quorum): Autodetect node ID when connecting to quorum members

* test(p2p/conn): remove unused privKeyWithNilPubKey

* doc(adr-d001): inter-validator set node id lookup

* refactor(quorum): apply code review feedback

* refactor(dash/types): rename package dashtypes to types

* refactor(p2p): make ValidateID exportable

* test(dash/types): increase validator address test coverage

* test(e2e): no node id in validator update address

* fix: node id not retrieved when processing val updates

* feat(dash/quorum): lookup node id in address book

* fix(dash/quorum): log validators list as single string

Convert validators map to string before logging. Without this
change, elasticsearch maps each validator as a separate field,
like:
`json.validators.1AD56AAACE6385A240B3A85EC231ACDE3972CD21A09678A7924B28116314A29C.address.Hostname`

* refactor: code comments, improved strings

* doc(adr-d001): update doc after implementation

* doc(adr-d001): apply feedback

Co-authored-by: shotonoff <shotonoff@gmail.com>

* fix: don't disconnect already disconnected validators

Fixed: Validator disconnected outside of Validator Set was not found in the Switch but never removed from ValidatorConnExecutor.connectedValidators.

* feat(consensus): add create_proof_block_range config option (#243)

Added create_proof_block_range configuration option to control the proof block creation algorithm.

* fix: cycle dependency in "types" package

* fix(types): modify and remove some test in types package

* refactor: remove unnecessary type conversion, update comment docs

* fix: light client package

* refactor: improve validator-set generator

* fix: some modification to ber able to run unit tests

* fix: increase MaxHeaderBytes till 646 bytes

* fix: TestTxFilter unit test at tx_filter_test.go

* fix: TestGCFifo, TestGCRandom, reduce a size of elements to 100

* wip: backport 0.7 on top of 0.8

* fix: Fix issues in 0.7 to 0.8 backport

* fix: e2e generator, remove UnmixedP2P and Legacy test cases

* refactor: remove a few unused variables and functions, clean up the code

* test(quorum): fix validar conn tests

* refactor: modification after PR feedback

* refactor: self-review of 0.7 -> 0.8 backport

* fix: validator address string should contain protocol

* fix: modify a light client to use default height as 0

* fix: update code style

* build(deps): bump github.com/prometheus/client_golang (#249)

Bumps [github.com/prometheus/client_golang](https://github.com/prometheus/client_golang) from 1.11.0 to 1.12.0.
- [Release notes](https://github.com/prometheus/client_golang/releases)
- [Changelog](https://github.com/prometheus/client_golang/blob/main/CHANGELOG.md)
- [Commits](prometheus/client_golang@v1.11.0...v1.12.0)

---
updated-dependencies:
- dependency-name: github.com/prometheus/client_golang
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* build(deps): bump github.com/BurntSushi/toml from 0.4.1 to 1.0.0

Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 0.4.1 to 1.0.0.
- [Release notes](https://github.com/BurntSushi/toml/releases)
- [Commits](BurntSushi/toml@v0.4.1...v1.0.0)

---
updated-dependencies:
- dependency-name: github.com/BurntSushi/toml
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

* chore(consensus): create only 1 proof block by default

* chore(release): release script and initial changelog (#250)

* feat(release): release script and initial change log

* chore(releaase): Update version release PR description

* chore(release)!: bump ABCI version and update release.sh to change TMVersionDefault automatically (#253)

* chore(release): update version in version/version.go

* chore(release)!: bump ABCI version and update release script

* fix(node): change TestMaxProposalBlockSize test to support tenderdash values and behaviour

* fix(ci): modify coverage.yml

* feat(quorum): port validator set connectivity to 0.8 (WIP)

* test(dash/quorum): Adjust unit tests for Tenderdash 0.8

Majority of changes are due to:

* defining that we cannot use `seed == 0` in mocks, as it's used
for TCP port numbers which should be 1-65535
* dialing each node individually inside ValidatorConnExecutor

* test(node): update node test to new data structures

* refactor(dash/quorum): rename Switch to DashConnectionManager

* refactor(p2p): remove unused code introduced in 0.7

* refactor(quorum): Code cleanup and renames for consistency

* refactor(dash/quorum): code comments and whitespace

* chore(release): update changelog and version to 0.7.0

Co-authored-by: shotonoff <dmitrii.golubev@dash.org>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: shotonoff <shotonoff@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants