mirror of
https://github.com/luxfi/netrunner.git
synced 2026-07-27 00:04:23 +00:00
improve efficiency at CreateSubnets
This commit is contained in:
+9
-15
@@ -333,11 +333,20 @@ func (ln *localNetwork) installSubnets(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wait for nodes to be primary validators before trying to add them as subnet ones
|
||||
if err = ln.waitPrimaryValidators(ctx, platformCli); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
subnetIDs, err := createSubnets(ctx, uint32(len(subnetSpecs)), w, ln.log)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = ln.addSubnetValidators(ctx, platformCli, w, subnetIDs, subnetSpecs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := ln.setSubnetConfigFiles(subnetIDs, subnetSpecs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -346,15 +355,6 @@ func (ln *localNetwork) installSubnets(
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// wait for nodes to be primary validators before trying to add them as subnet ones
|
||||
if err = ln.waitPrimaryValidators(ctx, platformCli); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = ln.addSubnetValidators(ctx, platformCli, w, subnetIDs, subnetSpecs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = ln.waitSubnetValidators(ctx, platformCli, subnetIDs, subnetSpecs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -910,12 +910,6 @@ func (ln *localNetwork) setBlockchainConfigFiles(
|
||||
delete(ln.nodes[nodeName].config.UpgradeConfigFiles, chainAlias)
|
||||
}
|
||||
}
|
||||
if chainSpec.SubnetConfig != nil {
|
||||
created = true
|
||||
for nodeName := range ln.nodes {
|
||||
ln.nodes[nodeName].config.SubnetConfigFiles[*chainSpec.SubnetID] = string(chainSpec.SubnetConfig)
|
||||
}
|
||||
}
|
||||
}
|
||||
return created
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,9 +22,9 @@ type BlockchainSpec struct {
|
||||
VMName string
|
||||
Genesis []byte
|
||||
SubnetID *string
|
||||
SubnetSpec *SubnetSpec
|
||||
ChainConfig []byte
|
||||
NetworkUpgrade []byte
|
||||
SubnetConfig []byte
|
||||
BlockchainAlias string
|
||||
PerNodeChainConfig map[string][]byte
|
||||
}
|
||||
|
||||
+15
-5
@@ -1220,8 +1220,8 @@ func getNetworkBlockchainSpec(
|
||||
}
|
||||
|
||||
var subnetConfigBytes []byte
|
||||
if spec.SubnetConfig != "" {
|
||||
subnetConfigBytes, err = os.ReadFile(spec.SubnetConfig)
|
||||
if spec.SubnetSpec != nil && spec.SubnetSpec.SubnetConfig != "" {
|
||||
subnetConfigBytes, err = os.ReadFile(spec.SubnetSpec.SubnetConfig)
|
||||
if err != nil {
|
||||
return network.BlockchainSpec{}, err
|
||||
}
|
||||
@@ -1247,16 +1247,26 @@ func getNetworkBlockchainSpec(
|
||||
perNodeChainConfig[nodeName] = cfgBytes
|
||||
}
|
||||
}
|
||||
return network.BlockchainSpec{
|
||||
|
||||
blockchainSpec := network.BlockchainSpec{
|
||||
VMName: vmName,
|
||||
Genesis: genesisBytes,
|
||||
ChainConfig: chainConfigBytes,
|
||||
NetworkUpgrade: networkUpgradeBytes,
|
||||
SubnetConfig: subnetConfigBytes,
|
||||
SubnetID: spec.SubnetId,
|
||||
BlockchainAlias: spec.BlockchainAlias,
|
||||
PerNodeChainConfig: perNodeChainConfig,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if spec.SubnetSpec != nil {
|
||||
subnetSpec := network.SubnetSpec{
|
||||
Participants: spec.SubnetSpec.Participants,
|
||||
SubnetConfig: subnetConfigBytes,
|
||||
}
|
||||
blockchainSpec.SubnetSpec = &subnetSpec
|
||||
}
|
||||
|
||||
return blockchainSpec, nil
|
||||
}
|
||||
|
||||
func getNetworkSubnetSpec(
|
||||
|
||||
Reference in New Issue
Block a user