@agoric/cosmos 0.34.2-dev-f6011d0.0 → 0.34.2-dev-4492e10.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
@@ -873,18 +873,23 @@ func NewAgoricApp(
873
873
  app.SetBeginBlocker(app.BeginBlocker)
874
874
  app.SetEndBlocker(app.EndBlocker)
875
875
 
876
- for name := range upgradeNamesOfThisVersion {
876
+ for _, name := range upgradeNamesOfThisVersion {
877
877
  app.UpgradeKeeper.SetUpgradeHandler(
878
878
  name,
879
879
  unreleasedUpgradeHandler(app, name),
880
880
  )
881
881
  }
882
882
 
883
+ // At this point we don't have a way to read from the store, so we have to
884
+ // rely on data saved by the x/upgrade module in the previous software.
883
885
  upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
884
886
  if err != nil {
885
887
  panic(err)
886
888
  }
887
- if upgradeNamesOfThisVersion[upgradeInfo.Name] && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
889
+ // Store migrations can only run once, so we use a notion of "primary upgrade
890
+ // name" to trigger them. Testnets may end up upgrading from one rc to
891
+ // another, which shouldn't re-run store upgrades.
892
+ if isPrimaryUpgradeName(upgradeInfo.Name) && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
888
893
  storeUpgrades := storetypes.StoreUpgrades{
889
894
  Added: []string{},
890
895
  Deleted: []string{},
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,15 +10,61 @@ import (
8
10
  upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
9
11
  )
10
12
 
11
- var upgradeNamesOfThisVersion = map[string]bool{
12
- "UNRELEASED_BASIC": true, // no-frills
13
- "UNRELEASED_A3P_INTEGRATION": true,
14
- "UNRELEASED_main": true,
15
- "UNRELEASED_devnet": true,
13
+ var upgradeNamesOfThisVersion = []string{
14
+ "UNRELEASED_BASIC", // no-frills
15
+ "UNRELEASED_A3P_INTEGRATION",
16
+ "UNRELEASED_main",
17
+ "UNRELEASED_devnet",
18
+ "UNRELEASED_REAPPLY",
19
+ }
20
+
21
+ // isUpgradeNameOfThisVersion returns whether the provided plan name is a
22
+ // known upgrade name of this software version
23
+ func isUpgradeNameOfThisVersion(name string) bool {
24
+ for _, upgradeName := range upgradeNamesOfThisVersion {
25
+ if upgradeName == name {
26
+ return true
27
+ }
28
+ }
29
+ return false
30
+ }
31
+
32
+ // validUpgradeName is an identity function that asserts the provided name
33
+ // is an upgrade name of this software version. It can be used as a sort of
34
+ // dynamic enum check.
35
+ func validUpgradeName(name string) string {
36
+ if !isUpgradeNameOfThisVersion(name) {
37
+ panic(fmt.Errorf("invalid upgrade name: %s", name))
38
+ }
39
+ return name
16
40
  }
17
41
 
42
+ // isPrimaryUpgradeName returns wether the provided plan name is considered a
43
+ // primary for the purpose of applying store migrations for the first upgrade
44
+ // of this version.
45
+ // It is expected that only primary plan names are used for non testing chains.
46
+ func isPrimaryUpgradeName(name string) bool {
47
+ if name == "" {
48
+ // An empty upgrade name can happen if there are no upgrade in progress
49
+ return false
50
+ }
51
+ switch name {
52
+ case validUpgradeName("UNRELEASED_BASIC"),
53
+ validUpgradeName("UNRELEASED_A3P_INTEGRATION"),
54
+ validUpgradeName("UNRELEASED_main"),
55
+ validUpgradeName("UNRELEASED_devnet"):
56
+ return true
57
+ case validUpgradeName("UNRELEASED_REAPPLY"):
58
+ return false
59
+ default:
60
+ panic(fmt.Errorf("unexpected upgrade name %s", validUpgradeName(name)))
61
+ }
62
+ }
63
+
64
+ // isFirstTimeUpgradeOfThisVersion looks up in the upgrade store whether no
65
+ // upgrade plan name of this version have previously been applied.
18
66
  func isFirstTimeUpgradeOfThisVersion(app *GaiaApp, ctx sdk.Context) bool {
19
- for name := range upgradeNamesOfThisVersion {
67
+ for _, name := range upgradeNamesOfThisVersion {
20
68
  if app.UpgradeKeeper.GetDoneHeight(ctx, name) != 0 {
21
69
  return false
22
70
  }
@@ -34,6 +82,13 @@ func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Conte
34
82
  // These CoreProposalSteps are not idempotent and should only be executed
35
83
  // as part of the first upgrade using this handler on any given chain.
36
84
  if isFirstTimeUpgradeOfThisVersion(app, ctx) {
85
+ // The storeUpgrades defined in app.go only execute for the primary upgrade name
86
+ // If we got here and this first upgrade of this version does not use the
87
+ // primary upgrade name, stores have not been initialized correctly.
88
+ if !isPrimaryUpgradeName(plan.Name) {
89
+ return module.VersionMap{}, fmt.Errorf("cannot run %s as first upgrade", plan.Name)
90
+ }
91
+
37
92
  // Each CoreProposalStep runs sequentially, and can be constructed from
38
93
  // one or more modules executing in parallel within the step.
39
94
  CoreProposalSteps = []vm.CoreProposalStep{
package/git-revision.txt CHANGED
@@ -1 +1 @@
1
- f6011d0
1
+ 4492e10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-f6011d0.0+f6011d0",
3
+ "version": "0.34.2-dev-4492e10.0+4492e10",
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": "f6011d0dd9a1364a6e70b71144a629050d2513fd"
42
+ "gitHead": "4492e102a1a0daee939318df6ba9c01acfb59475"
43
43
  }
@@ -31,6 +31,11 @@ const DefaultConfigTemplate = `
31
31
  # If relative, it is interpreted against the application home directory
32
32
  # (e.g., ~/.agoric).
33
33
  slogfile = "{{ .Swingset.SlogFile }}"
34
+
35
+ # The maximum number of vats that the SwingSet kernel will bring online. A lower number
36
+ # requires less memory but may have a negative performance impact if vats need to
37
+ # be frequently paged out to remain under this limit.
38
+ max_vats_online = {{ .Swingset.MaxVatsOnline }}
34
39
  `
35
40
 
36
41
  // SwingsetConfig defines configuration for the SwingSet VM.
@@ -38,10 +43,14 @@ slogfile = "{{ .Swingset.SlogFile }}"
38
43
  type SwingsetConfig struct {
39
44
  // SlogFile is the absolute path at which a SwingSet log "slog" file should be written.
40
45
  SlogFile string `mapstructure:"slogfile" json:"slogfile,omitempty"`
46
+ // MaxVatsOnline is the maximum number of vats that the SwingSet kernel will have online
47
+ // at any given time.
48
+ MaxVatsOnline int `mapstructure:"max_vats_online" json:"maxVatsOnline,omitempty"`
41
49
  }
42
50
 
43
51
  var DefaultSwingsetConfig = SwingsetConfig{
44
- SlogFile: "",
52
+ SlogFile: "",
53
+ MaxVatsOnline: 50,
45
54
  }
46
55
 
47
56
  func SwingsetConfigFromViper(resolvedConfig servertypes.AppOptions) (*SwingsetConfig, error) {