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

CreateSpecificBlockchains #467

Closed
wants to merge 35 commits into from
Closed

CreateSpecificBlockchains #467

wants to merge 35 commits into from

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented Mar 7, 2023

Replaces: #463

  • Register BLS Keys when adding new validators
  • Only restart nodes/track specific nodes
  • keep same backend across wallet restarts (to avoid duplicate UTXO usage)

@patrick-ogrady patrick-ogrady marked this pull request as draft March 7, 2023 20:28
local/blockchain.go Outdated Show resolved Hide resolved
@patrick-ogrady patrick-ogrady marked this pull request as ready for review March 7, 2023 22:20
@patrick-ogrady patrick-ogrady added the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 7, 2023
@patrick-ogrady patrick-ogrady removed the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 8, 2023
@patrick-ogrady patrick-ogrady added the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 8, 2023
@patrick-ogrady patrick-ogrady removed the DO NOT MERGE This PR is not meant to be merged in its current state label Mar 8, 2023
Copy link
Collaborator

@felipemadero felipemadero left a comment

Choose a reason for hiding this comment

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

I am ok to merge this, with comments addressed. Probably with all names changed to FoorBarExperimental. Probably also keeping server async, unless we want that change in server behaviour.
And as soon as posible, we may want to migrate this to local lib, following the style there. Probably overload CreateSubnets a little more with the funcitonality. Also avoid server to block, unless we will want server to be sync now. I am also tempted to enable AddNode to create multiple nodes, and to be more flexible regarding the options (not to ask for a full config). But this is the least idea.

rpcpb/rpc.proto Outdated

message CreateSpecificBlockchainsResponse {
ClusterInfo cluster_info = 1;
repeated CustomChainInfo chains = 2;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't this included in cluster_info? custom_chains

@@ -481,3 +489,13 @@ message GetSnapshotNamesRequest {
message GetSnapshotNamesResponse {
repeated string snapshot_names = 1;
}

message CreateSpecificBlockchainsRequest {
string exec_path = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

the function should take default network exec path probably, and have this one optional

@@ -481,3 +489,13 @@ message GetSnapshotNamesRequest {
message GetSnapshotNamesResponse {
repeated string snapshot_names = 1;
}

message CreateSpecificBlockchainsRequest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this functionality should belong to CreateBlockchains, maybe we can rename it to something-experimental to avoid user confusion

// validators, they will be added. This function blocks until all blockchains
// have been created and are healthy. This function returns the chains
// created and the participants that are on each chain.
//
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably also comment here that the nodes are also created

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would have added the node creation and subnet participation logic to CreateSubnetsExperimental, with multiple subnets configuration at a time. That is to be clear in breaking a 1-1 subnet-blockchain relation

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can call it CreateBlockchainsExperimental ?

defer ln.lock.Unlock()

// Create new subnets and blockchains
chainSpecs, chainIDs, err := experimental.CreateSpecificBlockchains(ctx, ln, execPath, chainSpecs, redirectOutput)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we can take execPath from ln.binaryPath, if not given, and let it be optional at a server level

if ready {
break
}
time.Sleep(1 * time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can use a select and time.After

return err
}
nodeIDs := make([]ids.NodeID, len(spec.Participants))
for i, nodeName := range spec.Participants {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can have a wallet function to add subnet validators also

)
}

// Wait for validators to become active
Copy link
Collaborator

Choose a reason for hiding this comment

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

also maybe this can be split, as a network may want to do something in the middle

if ready {
break
}
time.Sleep(1 * time.Second)
Copy link
Collaborator

Choose a reason for hiding this comment

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

select here?

// if err := ln.ReloadVMPluginsUnsafe(ctx); err != nil {
// return nil, nil, err
// }
if err := wallet.createBlockchains(ctx, chainSpecs, blockchainTxs); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

it is nice to see the same wallet can be used to issue the txs after it was also used to create those same tx with UTXOs and tx tracking

"github.com/ava-labs/avalanche-network-runner/rpcpb"
)

func deepCopy(i *rpcpb.ClusterInfo) (*rpcpb.ClusterInfo, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Testing this now in HyperSDK: ava-labs/hypersdk#95

Copy link
Contributor Author

@patrick-ogrady patrick-ogrady Mar 15, 2023

Choose a reason for hiding this comment

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

It may only be necessary to clone the strings in the chains field in CreateSpecificBlockchainsResponse (would reference same byte arrays as chainInfo).

Still researching why any of this would be related (assuming this actually solves the issue)...seems like gRPC should handle byte reuse in the marshaled response without issue and this is a bug elsewhere.

Copy link
Contributor Author

@patrick-ogrady patrick-ogrady Mar 15, 2023

Choose a reason for hiding this comment

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

It is also possible that there is a race such that clusterInfo changes while it is being encoded? (this seems unlikely given we aren't making calls concurrently)

}
return &rpcpb.CreateSpecificBlockchainsResponse{ClusterInfo: s.clusterInfo, Chains: chainIDs}, nil
return &rpcpb.CreateSpecificBlockchainsResponse{ClusterInfo: clusterInfo, Chains: chainIDs}, nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Technically, returning s.clusterInfo in this response is not safe as it may be modified as soon as the lock is released.

@felipemadero
Copy link
Collaborator

Closing. Pretty important PR with lots of new implementations! All of them where added to local/blockchain.go on v1.4.0. Thanks!

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

3 participants