Skip to content

Commit

Permalink
Merge branch 'main' into acp-77
Browse files Browse the repository at this point in the history
Signed-off-by: sukantoraymond <[email protected]>
  • Loading branch information
sukantoraymond authored Nov 14, 2024
2 parents ea37fed + 96046e3 commit ed04296
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 35 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-public-ami.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
aws-region: us-east-1

- name: Clean up old AMIs
run: npx aws-amicleaner --include-name 'public-avalanchecli-ubuntu-*' --exclude-newest 1 --exclude-days 2 --region="*" --force
run: npx aws-amicleaner --include-name 'public-avalanchecli-ubuntu-*' --exclude-newest 1 --region="*" --force
env:
AWS_REGION: us-east-1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
distribution: goreleaser
version: latest
version: 'v2.3.2'
args: release --clean
env:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.7
1.7.8
2 changes: 1 addition & 1 deletion cmd/blockchaincmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ func deployBlockchain(cmd *cobra.Command, args []string) error {
userProvidedAvagoVersion = avagoVersion
}

deployer := subnet.NewLocalDeployer(app, userProvidedAvagoVersion, avagoBinaryPath, vmBin)
deployer := subnet.NewLocalDeployer(app, userProvidedAvagoVersion, avagoBinaryPath, vmBin, true)
deployInfo, err := deployer.DeployToLocalNetwork(
chain,
genesisPath,
Expand Down
2 changes: 1 addition & 1 deletion cmd/networkcmd/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func clean(*cobra.Command, []string) error {

configSingleNodeEnabled := app.Conf.GetConfigBoolValue(constants.ConfigSingleNodeEnabledKey)

if _, err := subnet.SetDefaultSnapshot(app.GetSnapshotsDir(), true, "", configSingleNodeEnabled); err != nil {
if _, err := subnet.SetDefaultSnapshot(app.GetSnapshotsDir(), true, true, "", configSingleNodeEnabled); err != nil {
app.Log.Warn("failed resetting default snapshot", zap.Error(err))
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/networkcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func StartNetwork(*cobra.Command, []string) error {
return err
}
}
sd := subnet.NewLocalDeployer(app, avagoVersion, avagoBinaryPath, "")
sd := subnet.NewLocalDeployer(app, avagoVersion, avagoBinaryPath, "", false)

if err := sd.StartServer(
constants.ServerRunFileLocalNetworkPrefix,
Expand Down
4 changes: 3 additions & 1 deletion pkg/subnet/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"

"github.com/ava-labs/avalanche-cli/pkg/ux"
"github.com/ava-labs/avalanchego/utils/logging"
)

const (
Expand Down Expand Up @@ -97,7 +98,8 @@ func FindErrorLogs(rootDirs ...string) {
})
}
if len(foundErrors) > 0 {
ux.Logger.PrintToUser("================!!! end of errors in logs !!! ========================")
ux.Logger.PrintToUser(logging.Reset.Wrap("================!!! end of errors in logs !!! ========================"))
ux.Logger.PrintToUser("")
}
}

Expand Down
68 changes: 42 additions & 26 deletions pkg/subnet/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ import (
)

type LocalDeployer struct {
procChecker binutils.ProcessChecker
binChecker binutils.BinaryChecker
getClientFunc getGRPCClientFunc
binaryDownloader binutils.PluginBinaryDownloader
app *application.Avalanche
backendStartedHere bool
setDefaultSnapshot setDefaultSnapshotFunc
avagoVersion string
avagoBinaryPath string
vmBin string
procChecker binutils.ProcessChecker
binChecker binutils.BinaryChecker
getClientFunc getGRPCClientFunc
binaryDownloader binutils.PluginBinaryDownloader
app *application.Avalanche
backendStartedHere bool
setDefaultSnapshot setDefaultSnapshotFunc
avagoVersion string
avagoBinaryPath string
vmBin string
installSnapshotUpdates bool
}

// uses either avagoVersion or avagoBinaryPath
Expand All @@ -61,23 +62,25 @@ func NewLocalDeployer(
avagoVersion string,
avagoBinaryPath string,
vmBin string,
installSnapshotUpdates bool,
) *LocalDeployer {
return &LocalDeployer{
procChecker: binutils.NewProcessChecker(),
binChecker: binutils.NewBinaryChecker(),
getClientFunc: binutils.NewGRPCClient,
binaryDownloader: binutils.NewPluginBinaryDownloader(app),
app: app,
setDefaultSnapshot: SetDefaultSnapshot,
avagoVersion: avagoVersion,
avagoBinaryPath: avagoBinaryPath,
vmBin: vmBin,
procChecker: binutils.NewProcessChecker(),
binChecker: binutils.NewBinaryChecker(),
getClientFunc: binutils.NewGRPCClient,
binaryDownloader: binutils.NewPluginBinaryDownloader(app),
app: app,
setDefaultSnapshot: SetDefaultSnapshot,
avagoVersion: avagoVersion,
avagoBinaryPath: avagoBinaryPath,
vmBin: vmBin,
installSnapshotUpdates: installSnapshotUpdates,
}
}

type getGRPCClientFunc func(...binutils.GRPCClientOpOption) (client.Client, error)

type setDefaultSnapshotFunc func(string, bool, string, bool) (bool, error)
type setDefaultSnapshotFunc func(string, bool, bool, string, bool) (bool, error)

type ICMSpec struct {
SkipICMDeploy bool
Expand Down Expand Up @@ -636,7 +639,13 @@ func (d *LocalDeployer) SetupLocalEnv() (bool, string, error) {
}

configSingleNodeEnabled := d.app.Conf.GetConfigBoolValue(constants.ConfigSingleNodeEnabledKey)
needsRestart, err := d.setDefaultSnapshot(d.app.GetSnapshotsDir(), false, avagoVersion, configSingleNodeEnabled)
needsRestart, err := d.setDefaultSnapshot(
d.app.GetSnapshotsDir(),
false,
d.installSnapshotUpdates,
avagoVersion,
configSingleNodeEnabled,
)
if err != nil {
return false, "", fmt.Errorf("failed setting up snapshots: %w", err)
}
Expand Down Expand Up @@ -816,7 +825,13 @@ func getExpectedDefaultSnapshotSHA256Sum(

// Initialize default snapshot with bootstrap snapshot archive
// If force flag is set to true, overwrite the default snapshot if it exists
func SetDefaultSnapshot(snapshotsDir string, resetCurrentSnapshot bool, avagoVersion string, isSingleNode bool) (bool, error) {
func SetDefaultSnapshot(
snapshotsDir string,
resetCurrentSnapshot bool,
installUpdates bool,
avagoVersion string,
isSingleNode bool,
) (bool, error) {
var (
isPreCortina17 bool
isPreDurango11 bool
Expand Down Expand Up @@ -854,9 +869,10 @@ func SetDefaultSnapshot(snapshotsDir string, resetCurrentSnapshot bool, avagoVer
defaultSnapshotInUse = true
}
// will download either if file not exists or if sha256 sum is not the same
downloadSnapshot := false
missingArchive := false
checksumError := false
if _, err := os.Stat(bootstrapSnapshotArchivePath); os.IsNotExist(err) {
downloadSnapshot = true
missingArchive = true
} else {
gotSum, err := utils.GetSHA256FromDisk(bootstrapSnapshotArchivePath)
if err != nil {
Expand All @@ -866,10 +882,10 @@ func SetDefaultSnapshot(snapshotsDir string, resetCurrentSnapshot bool, avagoVer
if err != nil {
ux.Logger.PrintToUser("Warning: failure verifying that the local snapshot is the latest one: %s", err)
} else if gotSum != expectedSum {
downloadSnapshot = true
checksumError = true
}
}
if downloadSnapshot {
if missingArchive || (checksumError && installUpdates) {
resp, err := http.Get(url)
if err != nil {
return false, fmt.Errorf("failed downloading bootstrap snapshot: %w", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/subnet/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,6 @@ func getTestClientFunc(...binutils.GRPCClientOpOption) (client.Client, error) {
return c, nil
}

func fakeSetDefaultSnapshot(string, bool, string, bool) (bool, error) {
func fakeSetDefaultSnapshot(string, bool, bool, string, bool) (bool, error) {
return false, nil
}
2 changes: 1 addition & 1 deletion pkg/subnet/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type PublicDeployer struct {

func NewPublicDeployer(app *application.Avalanche, kc *keychain.Keychain, network models.Network) *PublicDeployer {
return &PublicDeployer{
LocalDeployer: *NewLocalDeployer(app, "", "", ""),
LocalDeployer: *NewLocalDeployer(app, "", "", "", false),
app: app,
kc: kc,
network: network,
Expand Down

0 comments on commit ed04296

Please sign in to comment.