@agoric/cosmos 0.35.0-upgrade-16-dev-1c6bbde.0 → 0.35.0-upgrade-16-dev-12b78e3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/app/app.go CHANGED
@@ -862,18 +862,23 @@ func NewAgoricApp(
862
862
  app.SetBeginBlocker(app.BeginBlocker)
863
863
  app.SetEndBlocker(app.EndBlocker)
864
864
 
865
- for name := range upgradeNamesOfThisVersion {
865
+ for _, name := range upgradeNamesOfThisVersion {
866
866
  app.UpgradeKeeper.SetUpgradeHandler(
867
867
  name,
868
868
  upgrade16Handler(app, name),
869
869
  )
870
870
  }
871
871
 
872
+ // At this point we don't have a way to read from the store, so we have to
873
+ // rely on data saved by the x/upgrade module in the previous software.
872
874
  upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
873
875
  if err != nil {
874
876
  panic(err)
875
877
  }
876
- if upgradeNamesOfThisVersion[upgradeInfo.Name] && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
878
+ // Store migrations can only run once, so we use a notion of "primary upgrade
879
+ // name" to trigger them. Testnets may end up upgrading from one rc to
880
+ // another, which shouldn't re-run store upgrades.
881
+ if isPrimaryUpgradeName(upgradeInfo.Name) && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
877
882
  storeUpgrades := storetypes.StoreUpgrades{
878
883
  Added: []string{
879
884
  packetforwardtypes.ModuleName, // Added PFM
package/app/upgrade.go CHANGED
@@ -1,6 +1,8 @@
1
1
  package gaia
2
2
 
3
3
  import (
4
+ "fmt"
5
+
4
6
  "github.com/Agoric/agoric-sdk/golang/cosmos/vm"
5
7
  swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
6
8
  sdk "github.com/cosmos/cosmos-sdk/types"
@@ -8,13 +10,23 @@ import (
8
10
  upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
9
11
  )
10
12
 
11
- var upgradeNamesOfThisVersion = map[string]bool{
12
- "agoric-upgrade-16": true,
13
- "agoric-upgrade-16-2": true,
13
+ var upgradeNamesOfThisVersion = []string{
14
+ "agoric-upgrade-16",
15
+ "agoric-upgrade-16-2",
16
+ }
17
+
18
+ // isPrimaryUpgradeName returns wether the provided plan name is considered a
19
+ // primary for the purpose of applying store migrations for the first upgrade
20
+ // of this version.
21
+ // It is expected that only primary plan names are used for non testing chains.
22
+ func isPrimaryUpgradeName(name string) bool {
23
+ return upgradeNamesOfThisVersion[0] == name
14
24
  }
15
25
 
26
+ // isFirstTimeUpgradeOfThisVersion looks up in the upgrade store whether no
27
+ // upgrade plan name of this version have previously been applied.
16
28
  func isFirstTimeUpgradeOfThisVersion(app *GaiaApp, ctx sdk.Context) bool {
17
- for name := range upgradeNamesOfThisVersion {
29
+ for _, name := range upgradeNamesOfThisVersion {
18
30
  if app.UpgradeKeeper.GetDoneHeight(ctx, name) != 0 {
19
31
  return false
20
32
  }
@@ -49,6 +61,13 @@ func upgrade16Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgr
49
61
  "@agoric/builders/scripts/vats/init-transfer.js",
50
62
  ),
51
63
  }
64
+
65
+ // The storeUpgrades defined in app.go only execute for the primary upgrade name
66
+ // If we got here and this first upgrade of this version does not use the
67
+ // primary upgrade name, stores have not been initialized correctly.
68
+ if !isPrimaryUpgradeName(plan.Name) {
69
+ return module.VersionMap{}, fmt.Errorf("cannot run %s as first upgrade", plan.Name)
70
+ }
52
71
  }
53
72
 
54
73
  app.upgradeDetails = &upgradeDetails{
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- 1c6bbde
1
+ 12b78e3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.35.0-upgrade-16-dev-1c6bbde.0+1c6bbde",
3
+ "version": "0.35.0-upgrade-16-dev-12b78e3.0+12b78e3",
4
4
  "description": "Connect JS to the Cosmos blockchain SDK",
5
5
  "parsers": {
6
6
  "js": "mjs"
@@ -39,5 +39,5 @@
39
39
  "typeCoverage": {
40
40
  "atLeast": 0
41
41
  },
42
- "gitHead": "1c6bbde8fefd6404a29710457e8ed4d60d6d7200"
42
+ "gitHead": "12b78e307e22d0dc0c95f40099300e16655781c4"
43
43
  }