Skip to content

Commit

Permalink
pass chain config + network upgrade down to local network
Browse files Browse the repository at this point in the history
  • Loading branch information
felipemadero committed Oct 22, 2022
1 parent a11d39c commit 4ce04fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
10 changes: 7 additions & 3 deletions local/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,12 +718,16 @@ func createBlockchains(
if err != nil {
return nil, err
}
vmGenesisBytes := chainSpec.Genesis
genesisBytes := chainSpec.Genesis
fmt.Println(string(chainSpec.Genesis))
fmt.Println(string(chainSpec.ChainConfig))
fmt.Println(string(chainSpec.NetworkUpgrade))
return nil, fmt.Errorf("pepe")

log.Info("creating blockchain tx",
zap.String("vm-name", vmName),
zap.String("vm-ID", vmID.String()),
zap.Int("bytes length of genesis", len(vmGenesisBytes)),
zap.Int("bytes length of genesis", len(genesisBytes)),
)
cctx, cancel := createDefaultCtx(ctx)
subnetID, err := ids.FromString(*chainSpec.SubnetId)
Expand All @@ -732,7 +736,7 @@ func createBlockchains(
}
blockchainID, err := baseWallet.P().IssueCreateChainTx(
subnetID,
vmGenesisBytes,
genesisBytes,
vmID,
nil,
vmName,
Expand Down
17 changes: 9 additions & 8 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ var (
)

const (
MinNodes uint32 = 1
DefaultNodes uint32 = 5
stopOnSignalTimeout = 2 * time.Second
MinNodes uint32 = 1
DefaultNodes uint32 = 5
stopTimeout = 2 * time.Second

rootDataDirPrefix = "network-runner-root-data"
)
Expand Down Expand Up @@ -212,7 +212,7 @@ func (s *server) Run(rootCtx context.Context) (err error) {
}

if s.network != nil {
stopCtx, stopCtxCancel := context.WithTimeout(context.Background(), stopOnSignalTimeout)
stopCtx, stopCtxCancel := context.WithTimeout(context.Background(), stopTimeout)
defer stopCtxCancel()
s.network.stop(stopCtx)
s.log.Warn("network stopped")
Expand Down Expand Up @@ -389,11 +389,12 @@ func (s *server) waitChAndUpdateClusterInfo(waitMsg string, readyCh chan struct{
case <-s.network.stopCh:
return
case serr := <-s.network.startErrCh:
// TODO: decide what to do here, general failure cause network stop()?
// maybe try decide if operation was partial (undesired network, fail)
// or was not stated (preconditions check, continue)
s.log.Warn("async call failed to complete", zap.String("async-call", waitMsg), zap.Error(serr))
panic(serr)
stopCtx, stopCtxCancel := context.WithTimeout(context.Background(), stopTimeout)
s.network.stop(stopCtx)
stopCtxCancel()
s.network = nil
s.clusterInfo = nil
case <-readyCh:
s.mu.Lock()
s.clusterInfo.Healthy = true
Expand Down

0 comments on commit 4ce04fb

Please sign in to comment.