@agoric/cosmos 0.32.3-pismo-dev-50dc068.0 → 0.33.1-dev-800c2bb.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/CHANGELOG.md +14 -0
- package/Makefile +1 -1
- package/app/app.go +109 -16
- package/app/const.go +2 -2
- package/daemon/cmd/root.go +8 -13
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +10 -0
- package/proto/agoric/swingset/swingset.proto +14 -0
- package/x/swingset/abci.go +24 -17
- package/x/swingset/alias.go +1 -0
- package/x/swingset/client/cli/tx.go +18 -0
- package/x/swingset/genesis.go +11 -6
- package/x/swingset/keeper/keeper.go +131 -56
- package/x/swingset/keeper/migrations.go +27 -0
- package/x/swingset/keeper/msg_server.go +23 -6
- package/x/swingset/keeper/proposal.go +1 -1
- package/x/swingset/keeper/querier.go +3 -3
- package/x/swingset/keeper/snapshotter.go +491 -0
- package/x/swingset/keeper/snapshotter_test.go +185 -0
- package/x/swingset/legacy/v32/params.go +37 -0
- package/x/swingset/legacy/v32/params_test.go +133 -0
- package/x/swingset/module.go +6 -1
- package/x/swingset/types/default-params.go +5 -2
- package/x/swingset/types/expected_keepers.go +1 -0
- package/x/swingset/types/msgs.go +156 -10
- package/x/swingset/types/msgs.pb.go +142 -47
- package/x/swingset/types/msgs_test.go +174 -0
- package/x/swingset/types/swingset.pb.go +280 -51
- package/x/swingset/types/types.go +1 -1
- package/x/vbank/README.md +1 -1
- package/x/vbank/keeper/keeper.go +15 -1
- package/x/vbank/module.go +13 -1
- package/x/vbank/types/expected_keepers.go +3 -1
- package/x/vbank/vbank.go +8 -0
- package/x/vbank/vbank_test.go +70 -9
- package/x/vstorage/keeper/grpc_query.go +2 -2
- package/x/vstorage/keeper/keeper.go +269 -38
- package/x/vstorage/keeper/keeper_test.go +162 -17
- package/x/vstorage/keeper/querier.go +4 -4
- package/x/vstorage/module.go +2 -0
- package/x/vstorage/types/path_keys.go +10 -3
- package/x/vstorage/types/types.go +66 -0
- package/x/vstorage/vstorage.go +118 -25
- package/x/vstorage/vstorage_test.go +297 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.33.0](https://github.com/Agoric/agoric-sdk/compare/@agoric/cosmos@0.32.2...@agoric/cosmos@0.33.0) (2023-02-17)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* null upgrade handler for upgrade-9 ([bfbc86f](https://github.com/Agoric/agoric-sdk/commit/bfbc86f32959c8e900bda3ed2bae7283e9975f66))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
* remove unneeded upgrade store loader ([e7a0ea0](https://github.com/Agoric/agoric-sdk/commit/e7a0ea0d8029ac131ca07ba90a4da210d4be6294))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
### [0.32.2](https://github.com/Agoric/agoric-sdk/compare/@agoric/cosmos@0.32.1...@agoric/cosmos@0.32.2) (2022-10-18)
|
|
7
21
|
|
|
8
22
|
|
package/Makefile
CHANGED
|
@@ -16,7 +16,7 @@ BIN := $(shell echo $${GOBIN-$${GOPATH-$$HOME/go}/bin})
|
|
|
16
16
|
include Makefile.ledger
|
|
17
17
|
|
|
18
18
|
whitespace :=
|
|
19
|
-
whitespace
|
|
19
|
+
whitespace := $(whitespace) $(whitespace)
|
|
20
20
|
comma := ,
|
|
21
21
|
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
|
|
22
22
|
|
package/app/app.go
CHANGED
|
@@ -109,6 +109,7 @@ import (
|
|
|
109
109
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/lien"
|
|
110
110
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
|
|
111
111
|
swingsetclient "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/client"
|
|
112
|
+
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
112
113
|
swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
113
114
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank"
|
|
114
115
|
vbanktypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
@@ -227,11 +228,12 @@ type GaiaApp struct { // nolint: golint
|
|
|
227
228
|
FeeGrantKeeper feegrantkeeper.Keeper
|
|
228
229
|
AuthzKeeper authzkeeper.Keeper
|
|
229
230
|
|
|
230
|
-
SwingSetKeeper
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
231
|
+
SwingSetKeeper swingset.Keeper
|
|
232
|
+
SwingSetSnapshotter swingset.Snapshotter
|
|
233
|
+
VstorageKeeper vstorage.Keeper
|
|
234
|
+
VibcKeeper vibc.Keeper
|
|
235
|
+
VbankKeeper vbank.Keeper
|
|
236
|
+
LienKeeper lien.Keeper
|
|
235
237
|
|
|
236
238
|
// make scoped keepers public for test purposes
|
|
237
239
|
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
|
@@ -447,6 +449,12 @@ func NewAgoricApp(
|
|
|
447
449
|
callToController,
|
|
448
450
|
)
|
|
449
451
|
|
|
452
|
+
app.SwingSetSnapshotter = swingsetkeeper.NewSwingsetSnapshotter(
|
|
453
|
+
bApp,
|
|
454
|
+
app.SwingSetKeeper,
|
|
455
|
+
sendToController,
|
|
456
|
+
)
|
|
457
|
+
|
|
450
458
|
app.VibcKeeper = vibc.NewKeeper(
|
|
451
459
|
appCodec, keys[vibc.StoreKey],
|
|
452
460
|
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
|
|
@@ -571,8 +579,8 @@ func NewAgoricApp(
|
|
|
571
579
|
params.NewAppModule(app.ParamsKeeper),
|
|
572
580
|
transferModule,
|
|
573
581
|
icaModule,
|
|
574
|
-
swingset.NewAppModule(app.SwingSetKeeper),
|
|
575
582
|
vstorage.NewAppModule(app.VstorageKeeper),
|
|
583
|
+
swingset.NewAppModule(app.SwingSetKeeper),
|
|
576
584
|
vibcModule,
|
|
577
585
|
vbankModule,
|
|
578
586
|
lienModule,
|
|
@@ -604,14 +612,13 @@ func NewAgoricApp(
|
|
|
604
612
|
feegrant.ModuleName,
|
|
605
613
|
paramstypes.ModuleName,
|
|
606
614
|
vestingtypes.ModuleName,
|
|
607
|
-
swingset.ModuleName,
|
|
608
615
|
vstorage.ModuleName,
|
|
616
|
+
swingset.ModuleName,
|
|
609
617
|
vibc.ModuleName,
|
|
610
618
|
vbank.ModuleName,
|
|
611
619
|
lien.ModuleName,
|
|
612
620
|
)
|
|
613
621
|
app.mm.SetOrderEndBlockers(
|
|
614
|
-
vstorage.ModuleName,
|
|
615
622
|
vibc.ModuleName,
|
|
616
623
|
vbank.ModuleName,
|
|
617
624
|
lien.ModuleName,
|
|
@@ -636,6 +643,8 @@ func NewAgoricApp(
|
|
|
636
643
|
vestingtypes.ModuleName,
|
|
637
644
|
// SwingSet needs to be last, for it to capture all the pushed actions.
|
|
638
645
|
swingset.ModuleName,
|
|
646
|
+
// And then vstorage, to produce SwingSet-induced events.
|
|
647
|
+
vstorage.ModuleName,
|
|
639
648
|
)
|
|
640
649
|
|
|
641
650
|
// NOTE: The genutils module must occur after staking so that pools are
|
|
@@ -735,11 +744,11 @@ func NewAgoricApp(
|
|
|
735
744
|
|
|
736
745
|
app.UpgradeKeeper.SetUpgradeHandler(
|
|
737
746
|
upgradeName,
|
|
738
|
-
|
|
747
|
+
upgrade10Handler(app, upgradeName),
|
|
739
748
|
)
|
|
740
749
|
app.UpgradeKeeper.SetUpgradeHandler(
|
|
741
750
|
upgradeNameTest,
|
|
742
|
-
|
|
751
|
+
upgrade10Handler(app, upgradeNameTest),
|
|
743
752
|
)
|
|
744
753
|
|
|
745
754
|
if loadLatest {
|
|
@@ -752,14 +761,67 @@ func NewAgoricApp(
|
|
|
752
761
|
app.ScopedVibcKeeper = scopedVibcKeeper
|
|
753
762
|
app.ScopedTransferKeeper = scopedTransferKeeper
|
|
754
763
|
app.ScopedICAHostKeeper = scopedICAHostKeeper
|
|
764
|
+
snapshotManager := app.SnapshotManager()
|
|
765
|
+
if snapshotManager != nil {
|
|
766
|
+
if err = snapshotManager.RegisterExtensions(&app.SwingSetSnapshotter); err != nil {
|
|
767
|
+
panic(fmt.Errorf("failed to register snapshot extension: %s", err))
|
|
768
|
+
}
|
|
769
|
+
}
|
|
755
770
|
|
|
756
771
|
return app
|
|
757
772
|
}
|
|
758
773
|
|
|
759
|
-
func
|
|
774
|
+
func upgrade10Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
760
775
|
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
761
|
-
|
|
776
|
+
// change bootrap gov parameter to correct vaults parameter
|
|
777
|
+
|
|
778
|
+
prevParams := app.SwingSetKeeper.GetParams(ctx)
|
|
779
|
+
|
|
780
|
+
ctx.Logger().Info("Pre-upgrade swingset params", "BeansPerUnit", fmt.Sprintf("%v", prevParams.BeansPerUnit), "BootstrapVatConfig", prevParams.BootstrapVatConfig)
|
|
781
|
+
|
|
782
|
+
switch targetUpgrade {
|
|
783
|
+
case upgradeName:
|
|
784
|
+
prevParams.BootstrapVatConfig = "@agoric/vats/decentral-main-vaults-config.json"
|
|
785
|
+
case upgradeNameTest:
|
|
786
|
+
prevParams.BootstrapVatConfig = "@agoric/vats/decentral-test-vaults-config.json"
|
|
787
|
+
default:
|
|
788
|
+
return fromVm, fmt.Errorf("invalid upgrade name")
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
app.SwingSetKeeper.SetParams(ctx, prevParams)
|
|
792
|
+
ctx.Logger().Info("Post-upgrade swingset params", "BeansPerUnit", fmt.Sprintf("%v", prevParams.BeansPerUnit), "BootstrapVatConfig", prevParams.BootstrapVatConfig)
|
|
793
|
+
|
|
794
|
+
app.VstorageKeeper.MigrateNoDataPlaceholders(ctx) // upgrade-10 only
|
|
795
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ProvisionPoolName)
|
|
796
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ReservePoolName)
|
|
797
|
+
|
|
798
|
+
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
|
|
799
|
+
if err != nil {
|
|
800
|
+
return mvm, err
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
// Just run the SwingSet kernel to finish bootstrap and get ready to open for
|
|
804
|
+
// business.
|
|
805
|
+
stdlog.Println("Rebooting SwingSet")
|
|
806
|
+
return mvm, swingset.BootSwingset(ctx, app.SwingSetKeeper)
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
// normalizeModuleAccount ensures that the given account is a module account,
|
|
811
|
+
// initializing or updating it if necessary. The account name must be listed in maccPerms.
|
|
812
|
+
func normalizeModuleAccount(ctx sdk.Context, ak authkeeper.AccountKeeper, name string) {
|
|
813
|
+
addr := ak.GetModuleAddress(name)
|
|
814
|
+
acct := ak.GetAccount(ctx, addr)
|
|
815
|
+
if _, ok := acct.(authtypes.ModuleAccountI); ok {
|
|
816
|
+
return
|
|
762
817
|
}
|
|
818
|
+
perms := maccPerms[name]
|
|
819
|
+
newAcct := authtypes.NewEmptyModuleAccount(name, perms...)
|
|
820
|
+
if acct != nil {
|
|
821
|
+
newAcct.AccountNumber = acct.GetAccountNumber()
|
|
822
|
+
newAcct.Sequence = acct.GetSequence()
|
|
823
|
+
}
|
|
824
|
+
ak.SetModuleAccount(ctx, newAcct)
|
|
763
825
|
}
|
|
764
826
|
|
|
765
827
|
type cosmosInitAction struct {
|
|
@@ -839,17 +901,44 @@ func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
|
|
839
901
|
stdlog.Printf("Genesis time %s is in %s\n", genTime, d)
|
|
840
902
|
}
|
|
841
903
|
|
|
904
|
+
// initialize the provision and reserve module accounts, to avoid their implicit creation
|
|
905
|
+
// as a default account upon receiving a transfer. See BockedAddrs().
|
|
906
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ProvisionPoolName)
|
|
907
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ReservePoolName)
|
|
908
|
+
|
|
842
909
|
return res
|
|
843
910
|
}
|
|
844
911
|
|
|
845
912
|
// Commit tells the controller that the block is commited
|
|
846
913
|
func (app *GaiaApp) Commit() abci.ResponseCommit {
|
|
914
|
+
err := app.SwingSetSnapshotter.WaitUntilSnapshotStarted()
|
|
915
|
+
|
|
916
|
+
if err != nil {
|
|
917
|
+
app.Logger().Error("swingset snapshot failed to start", "err", err)
|
|
918
|
+
}
|
|
919
|
+
|
|
847
920
|
// Frontrun the BaseApp's Commit method
|
|
848
|
-
err
|
|
921
|
+
err = swingset.CommitBlock(app.SwingSetKeeper)
|
|
922
|
+
if err != nil {
|
|
923
|
+
panic(err.Error())
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
res, snapshotHeight := app.BaseApp.CommitWithoutSnapshot()
|
|
927
|
+
|
|
928
|
+
err = swingset.AfterCommitBlock(app.SwingSetKeeper)
|
|
849
929
|
if err != nil {
|
|
850
930
|
panic(err.Error())
|
|
851
931
|
}
|
|
852
|
-
|
|
932
|
+
|
|
933
|
+
if snapshotHeight > 0 {
|
|
934
|
+
err = app.SwingSetSnapshotter.InitiateSnapshot(snapshotHeight)
|
|
935
|
+
|
|
936
|
+
if err != nil {
|
|
937
|
+
app.Logger().Error("failed to initiate swingset snapshot", "err", err)
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
return res
|
|
853
942
|
}
|
|
854
943
|
|
|
855
944
|
// LoadHeight loads a particular height
|
|
@@ -872,8 +961,12 @@ func (app *GaiaApp) ModuleAccountAddrs() map[string]bool {
|
|
|
872
961
|
func (app *GaiaApp) BlockedAddrs() map[string]bool {
|
|
873
962
|
modAccAddrs := make(map[string]bool)
|
|
874
963
|
for acc := range maccPerms {
|
|
875
|
-
// The provision
|
|
876
|
-
|
|
964
|
+
// The provision and reserve pools are not blocked from receiving funds.
|
|
965
|
+
// NOTE: because of this, these pools must be explicitly
|
|
966
|
+
// initialized as module accounts during bootstrap to avoid
|
|
967
|
+
// implicit creation as a default account when funds are received.
|
|
968
|
+
switch acc {
|
|
969
|
+
case vbanktypes.ProvisionPoolName, vbanktypes.ReservePoolName:
|
|
877
970
|
continue
|
|
878
971
|
}
|
|
879
972
|
modAccAddrs[authtypes.NewModuleAddress(acc).String()] = true
|
package/app/const.go
CHANGED
package/daemon/cmd/root.go
CHANGED
|
@@ -232,19 +232,14 @@ func (ac appCreator) newApp(
|
|
|
232
232
|
panic(err)
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
snapshotStore, err = snapshots.NewStore(snapshotDB, snapshotDir)
|
|
245
|
-
if err != nil {
|
|
246
|
-
panic(err)
|
|
247
|
-
}
|
|
235
|
+
snapshotDir := filepath.Join(cast.ToString(appOpts.Get(flags.FlagHome)), "data", "snapshots")
|
|
236
|
+
snapshotDB, err := sdk.NewLevelDB("metadata", snapshotDir)
|
|
237
|
+
if err != nil {
|
|
238
|
+
panic(err)
|
|
239
|
+
}
|
|
240
|
+
snapshotStore, err := snapshots.NewStore(snapshotDB, snapshotDir)
|
|
241
|
+
if err != nil {
|
|
242
|
+
panic(err)
|
|
248
243
|
}
|
|
249
244
|
|
|
250
245
|
return gaia.NewAgoricApp(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agoric/cosmos",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1-dev-800c2bb.0+800c2bb",
|
|
4
4
|
"description": "Connect JS to the Cosmos blockchain SDK",
|
|
5
5
|
"parsers": {
|
|
6
6
|
"js": "mjs"
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"access": "public"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "800c2bbed8ccb1e0fc24481c9f95027f95efc1fb"
|
|
51
51
|
}
|
|
@@ -122,6 +122,16 @@ message MsgInstallBundle {
|
|
|
122
122
|
(gogoproto.jsontag) = "submitter",
|
|
123
123
|
(gogoproto.moretags) = "yaml:\"submitter\""
|
|
124
124
|
];
|
|
125
|
+
// Either bundle or compressed_bundle will be set.
|
|
126
|
+
// Default compression algorithm is gzip.
|
|
127
|
+
bytes compressed_bundle = 3 [
|
|
128
|
+
(gogoproto.jsontag) = "compressedBundle",
|
|
129
|
+
(gogoproto.moretags) = "yaml:\"compressedBundle\""
|
|
130
|
+
];
|
|
131
|
+
// Size in bytes of uncompression of compressed_bundle.
|
|
132
|
+
int64 uncompressed_size = 4 [
|
|
133
|
+
(gogoproto.jsontag) = "uncompressedSize"
|
|
134
|
+
];
|
|
125
135
|
}
|
|
126
136
|
|
|
127
137
|
// MsgInstallBundleResponse is an empty acknowledgement that an install bundle
|
|
@@ -149,3 +149,17 @@ message Egress {
|
|
|
149
149
|
(gogoproto.moretags) = "yaml:\"powerFlags\""
|
|
150
150
|
];
|
|
151
151
|
}
|
|
152
|
+
|
|
153
|
+
// The payload messages used by swingset state-sync
|
|
154
|
+
message ExtensionSnapshotterArtifactPayload {
|
|
155
|
+
option (gogoproto.equal) = false;
|
|
156
|
+
string name = 1 [
|
|
157
|
+
(gogoproto.jsontag) = "name",
|
|
158
|
+
(gogoproto.moretags) = "yaml:\"name\""
|
|
159
|
+
];
|
|
160
|
+
|
|
161
|
+
bytes data = 2 [
|
|
162
|
+
(gogoproto.jsontag) = "data",
|
|
163
|
+
(gogoproto.moretags) = "yaml:\"data\""
|
|
164
|
+
];
|
|
165
|
+
}
|
package/x/swingset/abci.go
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
package swingset
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
-
// "fmt"
|
|
5
4
|
// "os"
|
|
6
|
-
"
|
|
5
|
+
"fmt"
|
|
7
6
|
"time"
|
|
8
7
|
|
|
9
8
|
"github.com/cosmos/cosmos-sdk/telemetry"
|
|
@@ -23,10 +22,6 @@ type beginBlockAction struct {
|
|
|
23
22
|
Params types.Params `json:"params"`
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
type beginBlockResult struct {
|
|
27
|
-
QueueAllowed []types.QueueSize `json:"queue_allowed"`
|
|
28
|
-
}
|
|
29
|
-
|
|
30
25
|
type endBlockAction struct {
|
|
31
26
|
Type string `json:"type"`
|
|
32
27
|
BlockHeight int64 `json:"blockHeight"`
|
|
@@ -50,20 +45,14 @@ func BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock, keeper Keeper) erro
|
|
|
50
45
|
ChainID: ctx.ChainID(),
|
|
51
46
|
Params: keeper.GetParams(ctx),
|
|
52
47
|
}
|
|
53
|
-
|
|
48
|
+
_, err := keeper.BlockingSend(ctx, action)
|
|
54
49
|
// fmt.Fprintf(os.Stderr, "BEGIN_BLOCK Returned from SwingSet: %s, %v\n", out, err)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
var result beginBlockResult
|
|
58
|
-
err := json.Unmarshal([]byte(out), &result)
|
|
59
|
-
if err != nil {
|
|
60
|
-
panic(err)
|
|
61
|
-
}
|
|
62
|
-
state := keeper.GetState(ctx)
|
|
63
|
-
state.QueueAllowed = result.QueueAllowed
|
|
64
|
-
keeper.SetState(ctx, state)
|
|
50
|
+
if err != nil {
|
|
51
|
+
panic(err)
|
|
65
52
|
}
|
|
66
53
|
|
|
54
|
+
err = keeper.UpdateQueueAllowed(ctx)
|
|
55
|
+
|
|
67
56
|
return err
|
|
68
57
|
}
|
|
69
58
|
|
|
@@ -112,3 +101,21 @@ func CommitBlock(keeper Keeper) error {
|
|
|
112
101
|
}
|
|
113
102
|
return err
|
|
114
103
|
}
|
|
104
|
+
|
|
105
|
+
func AfterCommitBlock(keeper Keeper) error {
|
|
106
|
+
// defer telemetry.ModuleMeasureSince(types.ModuleName, time.Now(), "commit_blocker")
|
|
107
|
+
|
|
108
|
+
action := &commitBlockAction{
|
|
109
|
+
Type: "AFTER_COMMIT_BLOCK",
|
|
110
|
+
BlockHeight: endBlockHeight,
|
|
111
|
+
BlockTime: endBlockTime,
|
|
112
|
+
}
|
|
113
|
+
_, err := keeper.BlockingSend(sdk.Context{}, action)
|
|
114
|
+
|
|
115
|
+
// fmt.Fprintf(os.Stderr, "AFTER_COMMIT_BLOCK Returned from SwingSet: %s, %v\n", out, err)
|
|
116
|
+
if err != nil {
|
|
117
|
+
// Panic here, in the hopes that a replay from scratch will fix the problem.
|
|
118
|
+
panic(fmt.Errorf("AFTER_COMMIT_BLOCK failed: %w. Swingset is in an irrecoverable inconsistent state", err))
|
|
119
|
+
}
|
|
120
|
+
return err
|
|
121
|
+
}
|
package/x/swingset/alias.go
CHANGED
|
@@ -20,6 +20,7 @@ import (
|
|
|
20
20
|
|
|
21
21
|
const (
|
|
22
22
|
FlagAllowSpend = "allow-spend"
|
|
23
|
+
FlagCompress = "compress"
|
|
23
24
|
)
|
|
24
25
|
|
|
25
26
|
func GetTxCmd(storeKey string) *cobra.Command {
|
|
@@ -122,9 +123,26 @@ func GetCmdInstallBundle() *cobra.Command {
|
|
|
122
123
|
return err
|
|
123
124
|
}
|
|
124
125
|
|
|
126
|
+
compress, err := cmd.Flags().GetBool(FlagCompress)
|
|
127
|
+
if err != nil {
|
|
128
|
+
return err
|
|
129
|
+
}
|
|
130
|
+
if compress {
|
|
131
|
+
err = msg.Compress()
|
|
132
|
+
if err != nil {
|
|
133
|
+
return err
|
|
134
|
+
}
|
|
135
|
+
// re-validate to be sure
|
|
136
|
+
err = msg.ValidateBasic()
|
|
137
|
+
if err != nil {
|
|
138
|
+
return err
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
125
142
|
return tx.GenerateOrBroadcastTxCLI(cctx, cmd.Flags(), msg)
|
|
126
143
|
},
|
|
127
144
|
}
|
|
145
|
+
cmd.Flags().Bool(FlagCompress, true, "Compress the bundle in transit")
|
|
128
146
|
flags.AddTxFlagsToCmd(cmd)
|
|
129
147
|
return cmd
|
|
130
148
|
}
|
package/x/swingset/genesis.go
CHANGED
|
@@ -37,13 +37,9 @@ type bootstrapBlockAction struct {
|
|
|
37
37
|
StoragePort int `json:"storagePort"`
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
func
|
|
41
|
-
|
|
42
|
-
keeper.SetState(ctx, data.GetState())
|
|
43
|
-
|
|
44
|
-
// Just run the SwingSet kernel to finish bootstrap and get ready to open for
|
|
40
|
+
func BootSwingset(ctx sdk.Context, keeper Keeper) error {
|
|
41
|
+
// Just run the SwingSet kernel to finish bootstrap and get ready to open for
|
|
45
42
|
// business.
|
|
46
|
-
stdlog.Println("Running SwingSet until bootstrap is ready")
|
|
47
43
|
action := &bootstrapBlockAction{
|
|
48
44
|
Type: "BOOTSTRAP_BLOCK",
|
|
49
45
|
BlockTime: ctx.BlockTime().Unix(),
|
|
@@ -51,7 +47,16 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abc
|
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
_, err := keeper.BlockingSend(ctx, action)
|
|
50
|
+
return err
|
|
51
|
+
}
|
|
54
52
|
|
|
53
|
+
func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) []abci.ValidatorUpdate {
|
|
54
|
+
keeper.SetParams(ctx, data.GetParams())
|
|
55
|
+
keeper.SetState(ctx, data.GetState())
|
|
56
|
+
|
|
57
|
+
stdlog.Println("Running SwingSet until bootstrap is ready")
|
|
58
|
+
err := BootSwingset(ctx, keeper)
|
|
59
|
+
|
|
55
60
|
// fmt.Fprintf(os.Stderr, "BOOTSTRAP_BLOCK Returned from swingset: %s, %v\n", out, err)
|
|
56
61
|
if err != nil {
|
|
57
62
|
// NOTE: A failed BOOTSTRAP_BLOCK means that the SwingSet state is inconsistent.
|