@agoric/cosmos 0.34.2-dev-91f5e93.0 → 0.34.2-dev-e28392f.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 +28 -29
- package/git-revision.txt +1 -1
- package/package.json +2 -2
- package/x/swingset/module.go +10 -6
package/app/app.go
CHANGED
|
@@ -598,7 +598,7 @@ func NewAgoricApp(
|
|
|
598
598
|
transferModule,
|
|
599
599
|
icaModule,
|
|
600
600
|
vstorage.NewAppModule(app.VstorageKeeper),
|
|
601
|
-
swingset.NewAppModule(app.SwingSetKeeper, setBootstrapNeeded),
|
|
601
|
+
swingset.NewAppModule(app.SwingSetKeeper, setBootstrapNeeded, app.ensureControllerInited),
|
|
602
602
|
vibcModule,
|
|
603
603
|
vbankModule,
|
|
604
604
|
lienModule,
|
|
@@ -631,6 +631,8 @@ func NewAgoricApp(
|
|
|
631
631
|
paramstypes.ModuleName,
|
|
632
632
|
vestingtypes.ModuleName,
|
|
633
633
|
vstorage.ModuleName,
|
|
634
|
+
// This will cause the swingset controller to init if it hadn't yet, passing
|
|
635
|
+
// any upgrade plan or bootstrap flag when starting at an upgrade height
|
|
634
636
|
swingset.ModuleName,
|
|
635
637
|
vibc.ModuleName,
|
|
636
638
|
vbank.ModuleName,
|
|
@@ -792,6 +794,7 @@ func NewAgoricApp(
|
|
|
792
794
|
// upgrade11Handler performs standard upgrade actions plus custom actions for upgrade-11.
|
|
793
795
|
func upgrade11Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
794
796
|
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
797
|
+
app.CheckControllerInited(false)
|
|
795
798
|
// Record the plan to send to SwingSet
|
|
796
799
|
app.upgradePlan = &plan
|
|
797
800
|
|
|
@@ -825,6 +828,7 @@ func normalizeModuleAccount(ctx sdk.Context, ak authkeeper.AccountKeeper, name s
|
|
|
825
828
|
type cosmosInitAction struct {
|
|
826
829
|
Type string `json:"type"`
|
|
827
830
|
ChainID string `json:"chainID"`
|
|
831
|
+
BlockTime int64 `json:"blockTime,omitempty"`
|
|
828
832
|
IsBootstrap bool `json:"isBootstrap"`
|
|
829
833
|
Params swingset.Params `json:"params"`
|
|
830
834
|
SupplyCoins sdk.Coins `json:"supplyCoins"`
|
|
@@ -849,13 +853,22 @@ func (app *GaiaApp) CheckControllerInited(expected bool) {
|
|
|
849
853
|
|
|
850
854
|
// initController sends the initialization message to the VM.
|
|
851
855
|
// Exits if the controller has already been initialized.
|
|
856
|
+
// The init message will contain any upgrade plan if we're starting after an
|
|
857
|
+
// upgrade, and a flag indicating whether this is a bootstrap of the controller.
|
|
852
858
|
func (app *GaiaApp) initController(ctx sdk.Context, bootstrap bool) {
|
|
853
859
|
app.CheckControllerInited(false)
|
|
854
860
|
app.controllerInited = true
|
|
861
|
+
|
|
862
|
+
var blockTime int64 = 0
|
|
863
|
+
if bootstrap || app.upgradePlan != nil {
|
|
864
|
+
blockTime = ctx.BlockTime().Unix()
|
|
865
|
+
}
|
|
866
|
+
|
|
855
867
|
// Begin initializing the controller here.
|
|
856
868
|
action := &cosmosInitAction{
|
|
857
869
|
Type: "AG_COSMOS_INIT",
|
|
858
870
|
ChainID: ctx.ChainID(),
|
|
871
|
+
BlockTime: blockTime,
|
|
859
872
|
IsBootstrap: bootstrap,
|
|
860
873
|
Params: app.SwingSetKeeper.GetParams(ctx),
|
|
861
874
|
SupplyCoins: sdk.NewCoins(app.BankKeeper.GetSupply(ctx, "uist")),
|
|
@@ -883,33 +896,24 @@ func (app *GaiaApp) initController(ctx sdk.Context, bootstrap bool) {
|
|
|
883
896
|
}
|
|
884
897
|
}
|
|
885
898
|
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
stdlog.Println("Running SwingSet until bootstrap is ready")
|
|
896
|
-
// Just run the SwingSet kernel to finish bootstrap and get ready to open for
|
|
897
|
-
// business.
|
|
898
|
-
action := &bootstrapBlockAction{
|
|
899
|
-
Type: "BOOTSTRAP_BLOCK",
|
|
900
|
-
BlockTime: ctx.BlockTime().Unix(),
|
|
899
|
+
// ensureControllerInited inits the controller if needed. It's used by the
|
|
900
|
+
// x/swingset module's BeginBlock to lazily start the JS controller.
|
|
901
|
+
// We cannot init early as we don't know when starting the software if this
|
|
902
|
+
// might be a simple restart, or a chain init from genesis or upgrade which
|
|
903
|
+
// require the controller to not be inited yet.
|
|
904
|
+
func (app *GaiaApp) ensureControllerInited(ctx sdk.Context) {
|
|
905
|
+
if app.controllerInited {
|
|
906
|
+
return
|
|
901
907
|
}
|
|
902
908
|
|
|
903
|
-
|
|
904
|
-
|
|
909
|
+
// While we don't expect it anymore, some upgrade may want to throw away
|
|
910
|
+
// the current JS state and bootstrap again (bulldozer). In that case the
|
|
911
|
+
// upgrade handler can just set the bootstrapNeeded flag.
|
|
912
|
+
app.initController(ctx, app.bootstrapNeeded)
|
|
905
913
|
}
|
|
906
914
|
|
|
907
915
|
// BeginBlocker application updates every begin block
|
|
908
916
|
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
|
|
909
|
-
if !app.controllerInited {
|
|
910
|
-
app.initController(ctx, false)
|
|
911
|
-
}
|
|
912
|
-
|
|
913
917
|
return app.mm.BeginBlock(ctx, req)
|
|
914
918
|
}
|
|
915
919
|
|
|
@@ -933,14 +937,9 @@ func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
|
|
933
937
|
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ProvisionPoolName)
|
|
934
938
|
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ReservePoolName)
|
|
935
939
|
|
|
940
|
+
// Init early (before first BeginBlock) to run the potentially lengthy bootstrap
|
|
936
941
|
if app.bootstrapNeeded {
|
|
937
|
-
|
|
938
|
-
// fmt.Fprintf(os.Stderr, "BOOTSTRAP_BLOCK Returned from swingset: %s, %v\n", out, err)
|
|
939
|
-
if err != nil {
|
|
940
|
-
// NOTE: A failed BOOTSTRAP_BLOCK means that the SwingSet state is inconsistent.
|
|
941
|
-
// Panic here, in the hopes that a replay from scratch will fix the problem.
|
|
942
|
-
panic(err)
|
|
943
|
-
}
|
|
942
|
+
app.initController(ctx, true)
|
|
944
943
|
}
|
|
945
944
|
|
|
946
945
|
// Agoric: report the genesis time explicitly.
|
package/git-revision.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
e28392f
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.34.2-dev-
|
|
3
|
+
"version": "0.34.2-dev-e28392f.0+e28392f",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "e28392f880293ee3398c739aeb0e6887feb897ec"
|
|
39
39
|
}
|
package/x/swingset/module.go
CHANGED
|
@@ -80,16 +80,18 @@ func (AppModuleBasic) GetTxCmd() *cobra.Command {
|
|
|
80
80
|
|
|
81
81
|
type AppModule struct {
|
|
82
82
|
AppModuleBasic
|
|
83
|
-
keeper
|
|
84
|
-
setBootstrapNeeded
|
|
83
|
+
keeper Keeper
|
|
84
|
+
setBootstrapNeeded func()
|
|
85
|
+
ensureControllerInited func(sdk.Context)
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
// NewAppModule creates a new AppModule Object
|
|
88
|
-
func NewAppModule(k Keeper, setBootstrapNeeded func()) AppModule {
|
|
89
|
+
func NewAppModule(k Keeper, setBootstrapNeeded func(), ensureControllerInited func(sdk.Context)) AppModule {
|
|
89
90
|
am := AppModule{
|
|
90
|
-
AppModuleBasic:
|
|
91
|
-
keeper:
|
|
92
|
-
setBootstrapNeeded:
|
|
91
|
+
AppModuleBasic: AppModuleBasic{},
|
|
92
|
+
keeper: k,
|
|
93
|
+
setBootstrapNeeded: setBootstrapNeeded,
|
|
94
|
+
ensureControllerInited: ensureControllerInited,
|
|
93
95
|
}
|
|
94
96
|
return am
|
|
95
97
|
}
|
|
@@ -127,6 +129,8 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
|
|
127
129
|
func (AppModule) ConsensusVersion() uint64 { return 2 }
|
|
128
130
|
|
|
129
131
|
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
|
132
|
+
am.ensureControllerInited(ctx)
|
|
133
|
+
|
|
130
134
|
err := BeginBlock(ctx, req, am.keeper)
|
|
131
135
|
if err != nil {
|
|
132
136
|
fmt.Println("BeginBlock error:", err)
|