add testcase and doc for creating two blockchains with disjoint bls

validators
This commit is contained in:
fm
2023-04-13 16:53:34 -03:00
parent 1f45304fd6
commit e4735cd09c
3 changed files with 104 additions and 7 deletions
+12 -2
View File
@@ -360,16 +360,26 @@ To create a blockchain with a subnet id, and chain config, network upgrade and s
curl -X POST -k http://localhost:8081/v1/control/createblockchains -d '{"pluginDir":"'$PLUGIN_DIR'","blockchainSpecs":[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_id": "'$SUBNET_ID'", "chain_config": "'$CHAIN_CONFIG_PATH'", "network_upgrade": "'$NETWORK_UPGRADE_PATH'", "subnet_config": "'$SUBNET_CONFIG_PATH'"}]}'
# or
avalanche-network-runner control create-blockchains '[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_id": "'$SUBNET_ID'", "chain_config": "'$CHAIN_CONFIG_PATH'", "network_upgrade": "'$NETWORK_UPGRADE_PATH'", "subnet_config": "'$SUBNET_CONFIG_PATH'"}]' --plugin-dir $PLUGIN_DIR
avalanche-network-runner control create-blockchains '[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_id": "'$SUBNET_ID'", "chain_config": "'$CHAIN_CONFIG_PATH'", "network_upgrade": "'$NETWORK_UPGRADE_PATH'", "subnet_config": "'$SUBNET_CONFIG_PATH'}]' --plugin-dir $PLUGIN_DIR
```
To create a blockchain with a new subnet id with select nodes as participants (requires network restart):
(New nodes will first be added as primary validators similar to the process in `create-subnets`)
```bash
curl -X POST -k http://localhost:8081/v1/control/createblockchains -d '{"pluginDir":"'$PLUGIN_DIR'","blockchainSpecs":[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": "{"participants": ["node1", "node2", "testNode"]}"]}'
# or
avalanche-network-runner control create-blockchains '[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": "{"participants": ["node1", "node2", "testNode"]}"]' --plugin-dir $PLUGIN_DIR
avalanche-network-runner control create-blockchains '[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": "{"participants": ["node1", "node2", "testNode"]}]' --plugin-dir $PLUGIN_DIR
```
To create two blockchains in two disjoint subnets (not shared validators), and where all validators have bls keys (parcipants new to the network):
```bash
curl -X POST -k http://localhost:8081/v1/control/createblockchains -d '{"pluginDir":"'$PLUGIN_DIR'","blockchainSpecs":[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": {"participants": ["new_node1", "new_node2"]}},{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": {"participants": ["new_node3", "new_node4"]}}]'
# or
go run main.go control create-blockchains '[{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": {"participants": ["new_node1", "new_node2"]}},{"vm_name":"'$VM_NAME'","genesis":"'$GENESIS_PATH'", "subnet_spec": {"participants": ["new_node3", "new_node4"]}}]'
```
Chain config can also be defined on a per node basis. For that, a per node chain config file is needed, which is a JSON that specifies the chain config per node. For example, given the following as the contents of the file with path `$PER_NODE_CHAIN_CONFIG`:
+1
View File
@@ -111,6 +111,7 @@ then
# download subnet-evm
# https://github.com/ava-labs/subnet-evm/releases
GOARCH=$(go env GOARCH)
GOOS=$(go env GOOS)
DOWNLOAD_URL=https://github.com/ava-labs/subnet-evm/releases/download/v${SUBNET_EVM_VERSION}/subnet-evm_${SUBNET_EVM_VERSION}_linux_${GOARCH}.tar.gz
DOWNLOAD_PATH=/tmp/subnet-evm.tar.gz
if [[ ${GOOS} == "darwin" ]]; then
+91 -5
View File
@@ -65,11 +65,15 @@ var (
"node6": `{"api-admin-enabled":false}`,
"node7": `{"api-admin-enabled":false}`,
}
numNodes = uint32(5)
subnetParticipants = []string{"node1", "node2", "node3"}
newParticipantNode = "newParticipantNode"
subnetParticipants2 = []string{"node1", "node2", newParticipantNode}
existingNodes = []string{"node1", "node2", "node3", "node4", "node5"}
numNodes = uint32(5)
subnetParticipants = []string{"node1", "node2", "node3"}
newParticipantNode = "newParticipantNode"
subnetParticipants2 = []string{"node1", "node2", newParticipantNode}
existingNodes = []string{"node1", "node2", "node3", "node4", "node5"}
disjointNewSubnetParticipants = [][]string{
{"new_node1", "new_node2"},
{"new_node3", "new_node4"},
}
)
func init() {
@@ -160,6 +164,7 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
ginkgo.It("can create blockhains", func() {
existingSubnetID := ""
createdBlockchainID := ""
createdBlockchainID2 := ""
ginkgo.By("start with blockchain specs", func() {
ux.Print(log, logging.Green.Wrap("sending 'start' with the valid binary path: %s"), execPath1)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)
@@ -363,6 +368,87 @@ var _ = ginkgo.Describe("[Start/Remove/Restart/Add/Stop]", func() {
gomega.Ω(err).Should(gomega.BeNil())
})
ginkgo.By("can create two blockchains in two new disjoint subnets with bls validators", func() {
// get prev status
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
prevStatus, err := cli.Status(ctx)
gomega.Ω(err).Should(gomega.BeNil())
cancel()
// create blockchains
ctx, cancel = context.WithTimeout(context.Background(), 2*time.Minute)
resp, err := cli.CreateBlockchains(ctx,
[]*rpcpb.BlockchainSpec{
{
VmName: "subnetevm",
Genesis: "tests/e2e/subnet-evm-genesis.json",
SubnetSpec: &rpcpb.SubnetSpec{Participants: disjointNewSubnetParticipants[0]},
},
{
VmName: "subnetevm",
Genesis: "tests/e2e/subnet-evm-genesis.json",
SubnetSpec: &rpcpb.SubnetSpec{Participants: disjointNewSubnetParticipants[1]},
},
},
)
cancel()
gomega.Ω(err).Should(gomega.BeNil())
// check new nodes
allNewParticipants := append(disjointNewSubnetParticipants[0], disjointNewSubnetParticipants[1]...)
expectedLen := len(prevStatus.ClusterInfo.NodeNames) + len(allNewParticipants)
gomega.Ω(len(resp.ClusterInfo.NodeNames)).Should(gomega.Equal(expectedLen))
for _, nodeName := range allNewParticipants {
_, ok := resp.ClusterInfo.NodeInfos[nodeName]
gomega.Ω(ok).Should(gomega.Equal(true))
}
gomega.Ω(len(resp.ChainIds)).Should(gomega.Equal(2))
createdBlockchainID = resp.ChainIds[0]
createdBlockchainID2 = resp.ChainIds[1]
})
ginkgo.By("verify the new subnets also has correct participants", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
status, err := cli.Status(ctx)
gomega.Ω(err).Should(gomega.BeNil())
customChains := status.ClusterInfo.GetCustomChains()
createdSubnetIDString := customChains[createdBlockchainID].SubnetId
subnetHasCorrectParticipants := utils.VerifySubnetHasCorrectParticipants(disjointNewSubnetParticipants[0], status.ClusterInfo, createdSubnetIDString)
gomega.Ω(subnetHasCorrectParticipants).Should(gomega.Equal(true))
createdSubnetID2String := customChains[createdBlockchainID2].SubnetId
subnet2HasCorrectParticipants := utils.VerifySubnetHasCorrectParticipants(disjointNewSubnetParticipants[1], status.ClusterInfo, createdSubnetID2String)
gomega.Ω(subnet2HasCorrectParticipants).Should(gomega.Equal(true))
})
ginkgo.By("verify that new validators have BLS Keys", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
clientURIs, err := cli.URIs(ctx)
gomega.Ω(err).Should(gomega.BeNil())
var clientURI string
for _, uri := range clientURIs {
clientURI = uri
break
}
platformCli := platformvm.NewClient(clientURI)
vdrs, err := platformCli.GetCurrentValidators(ctx, ids.Empty, nil)
gomega.Ω(err).Should(gomega.BeNil())
status, err := cli.Status(ctx)
gomega.Ω(err).Should(gomega.BeNil())
allNewParticipants := append(disjointNewSubnetParticipants[0], disjointNewSubnetParticipants[1]...)
for _, nodeName := range allNewParticipants {
nodeInfo, ok := status.ClusterInfo.NodeInfos[nodeName]
gomega.Ω(ok).Should(gomega.Equal(true))
found := false
for _, v := range vdrs {
if v.NodeID.String() == nodeInfo.Id {
gomega.Ω(v.Signer).Should(gomega.Not(gomega.BeNil()))
found = true
}
}
gomega.Ω(found).Should(gomega.Equal(true))
}
cancel()
})
ginkgo.By("can save snapshot", func() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
_, err := cli.SaveSnapshot(ctx, "test")