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

add '*' default value for --access-node-ids flag for LN/SN nodes #1426

Merged
merged 7 commits into from Oct 5, 2021

Conversation

kc1116
Copy link
Contributor

@kc1116 kc1116 commented Oct 4, 2021

This PR adds support for '*' value that can be set for the --acess-node-ids flag on LN & SN nodes. When this value is set LN/SN nodes will use ids of all the access nodes in the protocol state.

i.e :

--access-node-ids=*

@kc1116
Copy link
Contributor Author

kc1116 commented Oct 4, 2021

Follow up to this ticket https://github.com/dapperlabs/flow-internal/issues/1594

@codecov-commenter
Copy link

Codecov Report

Merging #1426 (f178ab0) into master (9d0c789) will decrease coverage by 0.01%.
The diff coverage is 50.58%.

❗ Current head f178ab0 differs from pull request most recent head 6aa08c2. Consider uploading reports for the commit 6aa08c2 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1426      +/-   ##
==========================================
- Coverage   55.41%   55.39%   -0.02%     
==========================================
  Files         512      512              
  Lines       31942    31964      +22     
==========================================
+ Hits        17700    17707       +7     
- Misses      11862    11873      +11     
- Partials     2380     2384       +4     
Flag Coverage Δ
unittests 55.39% <50.58%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
engine/consensus/ingestion/engine.go 45.63% <ø> (+0.12%) ⬆️
module/dkg/controller_factory.go 0.00% <0.00%> (ø)
module/dkg/broker.go 58.55% <46.80%> (-7.31%) ⬇️
module/epochs/qc_voter.go 59.67% <52.17%> (+1.34%) ⬆️
engine/collection/pusher/engine.go 65.38% <100.00%> (-0.66%) ⬇️
...ngine/common/synchronization/finalized_snapshot.go 68.75% <0.00%> (-4.17%) ⬇️
engine/collection/synchronization/engine.go 62.90% <0.00%> (-1.08%) ⬇️
...sus/approvals/assignment_collector_statemachine.go 47.11% <0.00%> (+4.80%) ⬆️

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 95cc399...6aa08c2. Read the comment docs.

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

One suggestion to disallow this new configuration for Mainnet, otherwise LGTM

@@ -384,7 +365,7 @@ func prepareConsensusService(container testnet.ContainerConfig, i int, accessNod
fmt.Sprintf("--chunk-alpha=1"),
fmt.Sprintf("--emergency-sealing-active=false"),
fmt.Sprintf("--insecure-access-api=false"),
fmt.Sprintf("--access-node-ids=%s", accessNodeIDS),
fmt.Sprint("--access-node-ids=*"),
Copy link
Member

Choose a reason for hiding this comment

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

👍

Comment on lines 209 to 213
if accessNodeIDS[0] == "*" {
anIDS, err = common.DefaultAccessNodeIDS(node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to get default access node ids %w", err)
}
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 we should explicitly disallow this configuration on Mainnet for now.

Suggested change
if accessNodeIDS[0] == "*" {
anIDS, err = common.DefaultAccessNodeIDS(node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to get default access node ids %w", err)
}
if accessNodeIDS[0] == "*" {
if node.ChainID == flow.Mainnet {
return fmt.Errorf("must specify preferred access node IDs for non-test networks")
}
anIDS, err = common.DefaultAccessNodeIDS(node.State.Sealed())
if err != nil {
return fmt.Errorf("failed to get default access node ids %w", err)
}


// if * provided use all ids in protocol state by default
if accessNodeIDS[0] == "*" {
anIDS, err = common.DefaultAccessNodeIDS(node.State.Sealed())
Copy link
Member

Choose a reason for hiding this comment

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

same here - disallow this configuration on mainnet

…ow/flow-go into khalil/1583-stake-node-util-func
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

This is very helpful, thank!

@@ -146,7 +146,7 @@ func main() {

// epoch qc contract flags
flags.BoolVar(&insecureAccessAPI, "insecure-access-api", false, "required if insecure GRPC connection should be used")
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. minimum length %d", common.DefaultAccessNodeIDSMinimum))
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node IDs sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -145,7 +145,7 @@ func main() {
flags.UintVar(&requiredApprovalsForSealConstruction, "required-construction-seal-approvals", sealing.DefaultRequiredApprovalsForSealConstruction, "minimum number of approvals that are required to construct a seal")
flags.BoolVar(&emergencySealing, "emergency-sealing-active", sealing.DefaultEmergencySealingActive, "(de)activation of emergency sealing")
flags.BoolVar(&insecureAccessAPI, "insecure-access-api", false, "required if insecure GRPC connection should be used")
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. minimum length %d", common.DefaultAccessNodeIDSMinimum))
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node ID's sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID after serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))
flags.StringSliceVar(&accessNodeIDS, "access-node-ids", []string{}, fmt.Sprintf("array of access node IDs sorted in priority order where the first ID in this array will get the first connection attempt and each subsequent ID serves as a fallback. Minimum length %d. Use '*' for all IDs in protocol state.", common.DefaultAccessNodeIDSMinimum))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

accessNodeIDS := make([]string, 0)
for i, c := range containers {
fmt.Printf("%d: %s", i+1, c.Identity().String())
if c.Unstaked {
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're removing this, you might as well remove the boolean flag Unstaked in integration/testnet/container.go. It's obsolete anyway. /cc @vishalchangrani for double-check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -139,3 +128,29 @@ func convertAccessAddrFromState(address string, insecureAccessAPI bool) string {

return accessAddress.String()
}

// DefaultAccessNodeIDS will return all the access node IDS in the protocol state for staked access nodes
func DefaultAccessNodeIDS(snapshot protocol.Snapshot) ([]flow.Identifier, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. This should probably never be allowed to return 0 IDs.
  2. This can return < 2 IDs. Depending on whether we're in a test situation, and. whether the test is specifically exercising AN fallback mechanisms, this may or may not be a bad thing. But I would at the very least log a warning there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add sanity check for 0 identities found 9abd914

As for 2. all tests explicitly enforce the access node ID minimum of 2 it's a requirement see here

…obsolete struct field ContainerConfig.Unstaked
@kc1116 kc1116 requested a review from huitseeker October 5, 2021 15:25
Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

🎸

cmd/util/cmd/common/validation.go Outdated Show resolved Hide resolved
Copy link
Contributor

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

Thanks a bunch!

Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
@kc1116
Copy link
Contributor Author

kc1116 commented Oct 5, 2021

bors merge

@bors
Copy link
Contributor

bors bot commented Oct 5, 2021

@bors bors bot merged commit 28862e1 into master Oct 5, 2021
@bors bors bot deleted the khalil/1595-access-node-ids-default branch October 5, 2021 17:11
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.

None yet

4 participants