@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-84eb287.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/MAINTAINERS.md +3 -0
- package/Makefile +67 -41
- package/agoric/config.go +35 -0
- package/ante/ante.go +65 -0
- package/ante/expected_keepers.go +26 -0
- package/ante/inbound.go +137 -0
- package/ante/inbound_test.go +228 -0
- package/ante/vm_admission.go +65 -0
- package/app/app.go +396 -211
- package/app/export.go +13 -9
- package/app/sim_test.go +4 -4
- package/app/upgrade.go +215 -0
- package/binding.gyp.in +29 -4
- package/buf.work.yaml +4 -0
- package/cmd/agd/agvm.go +42 -0
- package/cmd/agd/find_binary.go +22 -7
- package/cmd/agd/main.go +133 -10
- package/cmd/libdaemon/main.go +67 -53
- package/cmd/libdaemon/main_test.go +37 -0
- package/daemon/cmd/genaccounts.go +22 -18
- package/daemon/cmd/root.go +253 -52
- package/daemon/cmd/root_test.go +190 -2
- package/daemon/cmd/testnet.go +17 -6
- package/daemon/main.go +6 -3
- package/e2e_test/Makefile +29 -0
- package/e2e_test/README.md +100 -0
- package/e2e_test/go.mod +217 -0
- package/e2e_test/go.sum +1323 -0
- package/e2e_test/ibc_conformance_test.go +56 -0
- package/e2e_test/pfm_test.go +613 -0
- package/e2e_test/util.go +271 -0
- package/git-revision.txt +1 -0
- package/go.mod +207 -0
- package/go.sum +1877 -0
- package/package.json +13 -21
- package/proto/agoric/swingset/genesis.proto +14 -0
- package/proto/agoric/swingset/swingset.proto +6 -3
- package/proto/agoric/vlocalchain/.clang-format +7 -0
- package/proto/agoric/vlocalchain/vlocalchain.proto +31 -0
- package/proto/agoric/vstorage/query.proto +53 -1
- package/proto/agoric/vtransfer/genesis.proto +18 -0
- package/scripts/protocgen.sh +16 -6
- package/third_party/proto/buf.yaml +1 -0
- package/third_party/proto/cosmos/base/query/v1beta1/pagination.proto +4 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -4
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +16 -6
- package/third_party/proto/cosmos_proto/cosmos.proto +97 -0
- package/third_party/proto/google/api/annotations.proto +1 -1
- package/third_party/proto/google/api/http.proto +181 -120
- package/third_party/proto/google/api/httpbody.proto +9 -6
- package/third_party/proto/google/protobuf/any.proto +1 -7
- package/third_party/proto/ibc/core/channel/v1/channel.proto +15 -1
- package/third_party/proto/ibc/core/client/v1/client.proto +9 -6
- package/tools/tools.go +11 -0
- package/types/events.go +41 -0
- package/types/kv_entry.go +114 -0
- package/types/kv_entry_helpers.go +276 -0
- package/types/kv_entry_helpers_test.go +237 -0
- package/types/kv_entry_test.go +143 -0
- package/upgradegaia.sh +75 -0
- package/vm/action.go +134 -0
- package/vm/action_test.go +149 -0
- package/vm/client.go +113 -0
- package/vm/client_test.go +182 -0
- package/vm/controller.go +49 -0
- package/vm/core_proposals.go +51 -0
- package/vm/jsonrpcconn/jsonrpcconn.go +160 -0
- package/vm/jsonrpcconn/jsonrpcconn_test.go +126 -0
- package/vm/proto_json.go +38 -0
- package/vm/proto_json_test.go +103 -0
- package/vm/server.go +124 -0
- package/x/swingset/abci.go +26 -37
- package/x/swingset/alias.go +9 -6
- package/x/swingset/client/cli/query.go +2 -2
- package/x/swingset/client/cli/tx.go +52 -33
- package/x/swingset/client/proposal_handler.go +2 -17
- package/x/swingset/genesis.go +163 -37
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +309 -0
- package/x/swingset/keeper/extension_snapshotter_test.go +104 -0
- package/x/swingset/keeper/keeper.go +95 -48
- package/x/swingset/keeper/keeper_test.go +77 -0
- package/x/swingset/keeper/migrations.go +7 -2
- package/x/swingset/keeper/msg_server.go +71 -56
- package/x/swingset/keeper/proposal.go +15 -9
- package/x/swingset/keeper/querier.go +24 -15
- package/x/swingset/keeper/swing_store_exports_handler.go +872 -0
- package/x/swingset/keeper/swing_store_exports_handler_test.go +247 -0
- package/x/swingset/keeper/test_utils.go +16 -0
- package/x/swingset/module.go +33 -11
- package/x/swingset/proposal_handler.go +5 -4
- package/x/swingset/swingset.go +73 -0
- package/x/swingset/testing/queue.go +17 -0
- package/x/swingset/types/codec.go +2 -2
- package/x/swingset/types/default-params.go +23 -17
- package/x/swingset/types/expected_keepers.go +14 -2
- package/x/swingset/types/genesis.pb.go +361 -18
- package/x/swingset/types/msgs.go +87 -26
- package/x/swingset/types/msgs.pb.go +16 -16
- package/x/swingset/types/params.go +76 -1
- package/x/swingset/types/params_test.go +116 -0
- package/x/swingset/types/proposal.go +10 -9
- package/x/swingset/types/swingset.pb.go +83 -81
- package/x/swingset/types/types.go +30 -28
- package/x/vbank/genesis.go +0 -2
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/keeper.go +3 -2
- package/x/vbank/keeper/querier.go +9 -4
- package/x/vbank/keeper/rewards.go +1 -1
- package/x/vbank/module.go +0 -5
- package/x/vbank/types/msgs.go +0 -12
- package/x/vbank/vbank.go +34 -32
- package/x/vbank/vbank_test.go +20 -20
- package/x/vibc/alias.go +3 -0
- package/x/vibc/handler.go +17 -15
- package/x/vibc/keeper/keeper.go +113 -89
- package/x/vibc/keeper/triggers.go +101 -0
- package/x/vibc/module.go +5 -8
- package/x/vibc/types/expected_keepers.go +28 -6
- package/x/vibc/types/ibc_module.go +336 -0
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- package/x/vibc/types/receiver.go +170 -0
- package/x/vlocalchain/alias.go +19 -0
- package/x/vlocalchain/handler.go +21 -0
- package/x/vlocalchain/keeper/keeper.go +279 -0
- package/x/vlocalchain/keeper/keeper_test.go +97 -0
- package/x/vlocalchain/types/codec.go +34 -0
- package/x/vlocalchain/types/key.go +27 -0
- package/x/vlocalchain/types/msgs.go +16 -0
- package/x/vlocalchain/types/vlocalchain.pb.go +1072 -0
- package/x/vlocalchain/vlocalchain.go +114 -0
- package/x/vlocalchain/vlocalchain_test.go +434 -0
- package/x/vstorage/README.md +138 -0
- package/x/vstorage/capdata/capdata.go +298 -0
- package/x/vstorage/capdata/capdata_test.go +352 -0
- package/x/vstorage/client/cli/query.go +51 -4
- package/x/vstorage/genesis.go +0 -3
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/grpc_query.go +220 -0
- package/x/vstorage/keeper/keeper.go +75 -57
- package/x/vstorage/keeper/keeper_grpc_test.go +300 -0
- package/x/vstorage/keeper/keeper_test.go +40 -62
- package/x/vstorage/keeper/querier.go +39 -14
- package/x/vstorage/keeper/querier_test.go +113 -0
- package/x/vstorage/module.go +0 -5
- package/x/vstorage/testing/queue.go +27 -0
- package/x/vstorage/types/path_keys.go +22 -10
- package/x/vstorage/types/path_keys_test.go +84 -18
- package/x/vstorage/types/query.pb.go +646 -36
- package/x/vstorage/types/query.pb.gw.go +119 -0
- package/x/vstorage/types/types.go +0 -66
- package/x/vstorage/vstorage.go +33 -35
- package/x/vstorage/vstorage_test.go +19 -19
- package/x/vtransfer/alias.go +13 -0
- package/x/vtransfer/genesis.go +39 -0
- package/x/vtransfer/genesis_test.go +12 -0
- package/x/vtransfer/handler.go +20 -0
- package/x/vtransfer/ibc_middleware.go +186 -0
- package/x/vtransfer/ibc_middleware_test.go +448 -0
- package/x/vtransfer/keeper/keeper.go +281 -0
- package/x/vtransfer/module.go +124 -0
- package/x/vtransfer/types/expected_keepers.go +38 -0
- package/x/vtransfer/types/genesis.pb.go +327 -0
- package/x/vtransfer/types/key.go +9 -0
- package/x/vtransfer/types/msgs.go +9 -0
- package/app/const.go +0 -6
- package/cmd/helper/main.go +0 -21
- package/proto/agoric/lien/genesis.proto +0 -25
- package/proto/agoric/lien/lien.proto +0 -25
- package/x/lien/alias.go +0 -17
- package/x/lien/genesis.go +0 -58
- package/x/lien/genesis_test.go +0 -101
- package/x/lien/keeper/account.go +0 -285
- package/x/lien/keeper/keeper.go +0 -254
- package/x/lien/keeper/keeper_test.go +0 -623
- package/x/lien/lien.go +0 -203
- package/x/lien/lien_test.go +0 -529
- package/x/lien/module.go +0 -115
- package/x/lien/spec/01_concepts.md +0 -146
- package/x/lien/spec/02_messages.md +0 -96
- package/x/lien/types/accountkeeper.go +0 -81
- package/x/lien/types/accountstate.go +0 -27
- package/x/lien/types/expected_keepers.go +0 -18
- package/x/lien/types/genesis.pb.go +0 -567
- package/x/lien/types/key.go +0 -25
- package/x/lien/types/lien.pb.go +0 -403
- package/x/swingset/keeper/snapshotter.go +0 -491
- package/x/swingset/keeper/snapshotter_test.go +0 -185
- package/x/swingset/legacy/v32/params.go +0 -37
- package/x/swingset/legacy/v32/params_test.go +0 -133
- package/x/vibc/ibc.go +0 -442
- /package/{src/index.cjs → index.cjs} +0 -0
package/app/app.go
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package gaia
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"context"
|
|
4
5
|
"encoding/json"
|
|
5
6
|
"fmt"
|
|
6
7
|
"io"
|
|
@@ -8,24 +9,26 @@ import (
|
|
|
8
9
|
"net/http"
|
|
9
10
|
"os"
|
|
10
11
|
"path/filepath"
|
|
12
|
+
"runtime/debug"
|
|
11
13
|
"time"
|
|
12
14
|
|
|
15
|
+
sdkioerrors "cosmossdk.io/errors"
|
|
13
16
|
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
14
17
|
"github.com/cosmos/cosmos-sdk/client"
|
|
18
|
+
nodeservice "github.com/cosmos/cosmos-sdk/client/grpc/node"
|
|
15
19
|
"github.com/cosmos/cosmos-sdk/client/grpc/tmservice"
|
|
16
|
-
"github.com/cosmos/cosmos-sdk/client/rpc"
|
|
17
20
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
18
21
|
"github.com/cosmos/cosmos-sdk/codec/types"
|
|
19
22
|
"github.com/cosmos/cosmos-sdk/server/api"
|
|
20
23
|
"github.com/cosmos/cosmos-sdk/server/config"
|
|
21
24
|
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
22
25
|
"github.com/cosmos/cosmos-sdk/simapp"
|
|
26
|
+
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
23
27
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
24
28
|
"github.com/cosmos/cosmos-sdk/types/module"
|
|
25
29
|
"github.com/cosmos/cosmos-sdk/version"
|
|
26
30
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
|
27
31
|
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
|
28
|
-
authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest"
|
|
29
32
|
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
|
30
33
|
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
|
31
34
|
authtx "github.com/cosmos/cosmos-sdk/x/auth/tx"
|
|
@@ -41,9 +44,6 @@ import (
|
|
|
41
44
|
"github.com/cosmos/cosmos-sdk/x/capability"
|
|
42
45
|
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
|
43
46
|
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
44
|
-
"github.com/cosmos/cosmos-sdk/x/crisis"
|
|
45
|
-
crisiskeeper "github.com/cosmos/cosmos-sdk/x/crisis/keeper"
|
|
46
|
-
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
|
|
47
47
|
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
|
48
48
|
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
|
|
49
49
|
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
|
@@ -57,8 +57,11 @@ import (
|
|
|
57
57
|
"github.com/cosmos/cosmos-sdk/x/genutil"
|
|
58
58
|
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"
|
|
59
59
|
"github.com/cosmos/cosmos-sdk/x/gov"
|
|
60
|
+
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
|
|
60
61
|
govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper"
|
|
61
62
|
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
|
63
|
+
govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
|
64
|
+
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
|
62
65
|
"github.com/cosmos/cosmos-sdk/x/mint"
|
|
63
66
|
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
|
64
67
|
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
|
@@ -77,22 +80,22 @@ import (
|
|
|
77
80
|
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
|
|
78
81
|
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
|
|
79
82
|
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
|
80
|
-
ica "github.com/cosmos/ibc-go/
|
|
81
|
-
|
|
82
|
-
icahost "github.com/cosmos/ibc-go/
|
|
83
|
-
icahostkeeper "github.com/cosmos/ibc-go/
|
|
84
|
-
icahosttypes "github.com/cosmos/ibc-go/
|
|
85
|
-
icatypes "github.com/cosmos/ibc-go/
|
|
86
|
-
"github.com/cosmos/ibc-go/
|
|
87
|
-
ibctransferkeeper "github.com/cosmos/ibc-go/
|
|
88
|
-
ibctransfertypes "github.com/cosmos/ibc-go/
|
|
89
|
-
ibc "github.com/cosmos/ibc-go/
|
|
90
|
-
ibcclient "github.com/cosmos/ibc-go/
|
|
91
|
-
ibcclientclient "github.com/cosmos/ibc-go/
|
|
92
|
-
ibcclienttypes "github.com/cosmos/ibc-go/
|
|
93
|
-
|
|
94
|
-
ibchost "github.com/cosmos/ibc-go/
|
|
95
|
-
ibckeeper "github.com/cosmos/ibc-go/
|
|
83
|
+
ica "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts"
|
|
84
|
+
|
|
85
|
+
icahost "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host"
|
|
86
|
+
icahostkeeper "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/keeper"
|
|
87
|
+
icahosttypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/host/types"
|
|
88
|
+
icatypes "github.com/cosmos/ibc-go/v6/modules/apps/27-interchain-accounts/types"
|
|
89
|
+
ibctransfer "github.com/cosmos/ibc-go/v6/modules/apps/transfer"
|
|
90
|
+
ibctransferkeeper "github.com/cosmos/ibc-go/v6/modules/apps/transfer/keeper"
|
|
91
|
+
ibctransfertypes "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types"
|
|
92
|
+
ibc "github.com/cosmos/ibc-go/v6/modules/core"
|
|
93
|
+
ibcclient "github.com/cosmos/ibc-go/v6/modules/core/02-client"
|
|
94
|
+
ibcclientclient "github.com/cosmos/ibc-go/v6/modules/core/02-client/client"
|
|
95
|
+
ibcclienttypes "github.com/cosmos/ibc-go/v6/modules/core/02-client/types"
|
|
96
|
+
ibcporttypes "github.com/cosmos/ibc-go/v6/modules/core/05-port/types"
|
|
97
|
+
ibchost "github.com/cosmos/ibc-go/v6/modules/core/24-host"
|
|
98
|
+
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
|
|
96
99
|
"github.com/gorilla/mux"
|
|
97
100
|
"github.com/rakyll/statik/fs"
|
|
98
101
|
"github.com/spf13/cast"
|
|
@@ -100,13 +103,16 @@ import (
|
|
|
100
103
|
tmjson "github.com/tendermint/tendermint/libs/json"
|
|
101
104
|
"github.com/tendermint/tendermint/libs/log"
|
|
102
105
|
tmos "github.com/tendermint/tendermint/libs/os"
|
|
106
|
+
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
|
103
107
|
dbm "github.com/tendermint/tm-db"
|
|
104
108
|
|
|
105
109
|
gaiaappparams "github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
106
110
|
|
|
107
111
|
appante "github.com/Agoric/agoric-sdk/golang/cosmos/ante"
|
|
112
|
+
agorictypes "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
113
|
+
|
|
114
|
+
// conv "github.com/Agoric/agoric-sdk/golang/cosmos/types/conv"
|
|
108
115
|
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
109
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/x/lien"
|
|
110
116
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset"
|
|
111
117
|
swingsetclient "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/client"
|
|
112
118
|
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
@@ -114,7 +120,16 @@ import (
|
|
|
114
120
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank"
|
|
115
121
|
vbanktypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
116
122
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vibc"
|
|
123
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vlocalchain"
|
|
117
124
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage"
|
|
125
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer"
|
|
126
|
+
vtransferkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/keeper"
|
|
127
|
+
testtypes "github.com/cosmos/ibc-go/v6/testing/types"
|
|
128
|
+
|
|
129
|
+
// Import the packet forward middleware
|
|
130
|
+
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward"
|
|
131
|
+
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/keeper"
|
|
132
|
+
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"
|
|
118
133
|
|
|
119
134
|
// unnamed import of statik for swagger UI support
|
|
120
135
|
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
|
|
@@ -122,6 +137,14 @@ import (
|
|
|
122
137
|
|
|
123
138
|
const appName = "agoric"
|
|
124
139
|
|
|
140
|
+
// FlagSwingStoreExportDir defines the config flag used to specify where a
|
|
141
|
+
// genesis swing-store export is expected. For start from genesis, the default
|
|
142
|
+
// value is config/swing-store in the home directory. For genesis export, the
|
|
143
|
+
// value is always a "swing-store" directory sibling to the exported
|
|
144
|
+
// genesis.json file.
|
|
145
|
+
// TODO: document this flag in config, likely alongside the genesis path
|
|
146
|
+
const FlagSwingStoreExportDir = "swing-store-export-dir"
|
|
147
|
+
|
|
125
148
|
var (
|
|
126
149
|
// DefaultNodeHome default home directories for the application daemon
|
|
127
150
|
DefaultNodeHome string
|
|
@@ -137,31 +160,31 @@ var (
|
|
|
137
160
|
staking.AppModuleBasic{},
|
|
138
161
|
mint.AppModuleBasic{},
|
|
139
162
|
distr.AppModuleBasic{},
|
|
140
|
-
gov.NewAppModuleBasic(
|
|
163
|
+
gov.NewAppModuleBasic([]govclient.ProposalHandler{
|
|
141
164
|
paramsclient.ProposalHandler,
|
|
142
165
|
distrclient.ProposalHandler,
|
|
143
|
-
upgradeclient.
|
|
144
|
-
upgradeclient.
|
|
166
|
+
upgradeclient.LegacyProposalHandler,
|
|
167
|
+
upgradeclient.LegacyCancelProposalHandler,
|
|
145
168
|
ibcclientclient.UpdateClientProposalHandler,
|
|
146
169
|
ibcclientclient.UpgradeProposalHandler,
|
|
147
170
|
swingsetclient.CoreEvalProposalHandler,
|
|
148
|
-
),
|
|
171
|
+
}),
|
|
149
172
|
params.AppModuleBasic{},
|
|
150
|
-
crisis.AppModuleBasic{},
|
|
151
173
|
slashing.AppModuleBasic{},
|
|
152
174
|
feegrantmodule.AppModuleBasic{},
|
|
153
175
|
authzmodule.AppModuleBasic{},
|
|
154
176
|
ibc.AppModuleBasic{},
|
|
155
177
|
upgrade.AppModuleBasic{},
|
|
156
178
|
evidence.AppModuleBasic{},
|
|
157
|
-
|
|
179
|
+
ibctransfer.AppModuleBasic{},
|
|
158
180
|
vesting.AppModuleBasic{},
|
|
159
181
|
ica.AppModuleBasic{},
|
|
182
|
+
packetforward.AppModuleBasic{},
|
|
160
183
|
swingset.AppModuleBasic{},
|
|
161
184
|
vstorage.AppModuleBasic{},
|
|
162
185
|
vibc.AppModuleBasic{},
|
|
163
186
|
vbank.AppModuleBasic{},
|
|
164
|
-
|
|
187
|
+
vtransfer.AppModuleBasic{},
|
|
165
188
|
)
|
|
166
189
|
|
|
167
190
|
// module account permissions
|
|
@@ -196,17 +219,25 @@ type GaiaApp struct { // nolint: golint
|
|
|
196
219
|
interfaceRegistry types.InterfaceRegistry
|
|
197
220
|
|
|
198
221
|
controllerInited bool
|
|
199
|
-
|
|
222
|
+
bootstrapNeeded bool
|
|
223
|
+
swingsetPort int
|
|
200
224
|
vbankPort int
|
|
201
225
|
vibcPort int
|
|
202
226
|
vstoragePort int
|
|
227
|
+
vlocalchainPort int
|
|
228
|
+
vtransferPort int
|
|
229
|
+
|
|
230
|
+
upgradeDetails *upgradeDetails
|
|
203
231
|
|
|
204
232
|
invCheckPeriod uint
|
|
205
233
|
|
|
206
234
|
// keys to access the substores
|
|
207
|
-
keys map[string]*
|
|
208
|
-
tkeys map[string]*
|
|
209
|
-
memKeys map[string]*
|
|
235
|
+
keys map[string]*storetypes.KVStoreKey
|
|
236
|
+
tkeys map[string]*storetypes.TransientStoreKey
|
|
237
|
+
memKeys map[string]*storetypes.MemoryStoreKey
|
|
238
|
+
|
|
239
|
+
// manage communication from the VM to the ABCI app
|
|
240
|
+
AgdServer *vm.AgdServer
|
|
210
241
|
|
|
211
242
|
// keepers
|
|
212
243
|
AccountKeeper authkeeper.AccountKeeper
|
|
@@ -217,23 +248,25 @@ type GaiaApp struct { // nolint: golint
|
|
|
217
248
|
MintKeeper mintkeeper.Keeper
|
|
218
249
|
DistrKeeper distrkeeper.Keeper
|
|
219
250
|
GovKeeper govkeeper.Keeper
|
|
220
|
-
CrisisKeeper crisiskeeper.Keeper
|
|
221
251
|
UpgradeKeeper upgradekeeper.Keeper
|
|
222
252
|
ParamsKeeper paramskeeper.Keeper
|
|
223
253
|
// IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
|
|
224
|
-
IBCKeeper
|
|
225
|
-
ICAHostKeeper
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
254
|
+
IBCKeeper *ibckeeper.Keeper
|
|
255
|
+
ICAHostKeeper icahostkeeper.Keeper
|
|
256
|
+
PacketForwardKeeper *packetforwardkeeper.Keeper
|
|
257
|
+
EvidenceKeeper evidencekeeper.Keeper
|
|
258
|
+
TransferKeeper ibctransferkeeper.Keeper
|
|
259
|
+
FeeGrantKeeper feegrantkeeper.Keeper
|
|
260
|
+
AuthzKeeper authzkeeper.Keeper
|
|
261
|
+
|
|
262
|
+
SwingStoreExportsHandler swingset.SwingStoreExportsHandler
|
|
263
|
+
SwingSetSnapshotter swingset.ExtensionSnapshotter
|
|
264
|
+
SwingSetKeeper swingset.Keeper
|
|
265
|
+
VstorageKeeper vstorage.Keeper
|
|
266
|
+
VibcKeeper vibc.Keeper
|
|
267
|
+
VbankKeeper vbank.Keeper
|
|
268
|
+
VlocalchainKeeper vlocalchain.Keeper
|
|
269
|
+
VtransferKeeper vtransferkeeper.Keeper
|
|
237
270
|
|
|
238
271
|
// make scoped keepers public for test purposes
|
|
239
272
|
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
|
@@ -270,19 +303,18 @@ func NewGaiaApp(
|
|
|
270
303
|
appOpts servertypes.AppOptions,
|
|
271
304
|
baseAppOptions ...func(*baseapp.BaseApp),
|
|
272
305
|
) *GaiaApp {
|
|
273
|
-
defaultController
|
|
274
|
-
fmt.
|
|
275
|
-
return "", nil
|
|
306
|
+
var defaultController vm.Sender = func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
|
|
307
|
+
return "", fmt.Errorf("unexpected VM upcall with no controller: %s", jsonRequest)
|
|
276
308
|
}
|
|
277
309
|
return NewAgoricApp(
|
|
278
|
-
defaultController,
|
|
310
|
+
defaultController, vm.NewAgdServer(),
|
|
279
311
|
logger, db, traceStore, loadLatest, skipUpgradeHeights,
|
|
280
312
|
homePath, invCheckPeriod, encodingConfig, appOpts, baseAppOptions...,
|
|
281
313
|
)
|
|
282
314
|
}
|
|
283
315
|
|
|
284
316
|
func NewAgoricApp(
|
|
285
|
-
sendToController
|
|
317
|
+
sendToController vm.Sender, agdServer *vm.AgdServer,
|
|
286
318
|
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
|
|
287
319
|
homePath string, invCheckPeriod uint, encodingConfig gaiaappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
|
|
288
320
|
) *GaiaApp {
|
|
@@ -299,15 +331,17 @@ func NewAgoricApp(
|
|
|
299
331
|
authtypes.StoreKey, banktypes.StoreKey, stakingtypes.StoreKey,
|
|
300
332
|
minttypes.StoreKey, distrtypes.StoreKey, slashingtypes.StoreKey,
|
|
301
333
|
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
|
|
302
|
-
evidencetypes.StoreKey, ibctransfertypes.StoreKey,
|
|
334
|
+
evidencetypes.StoreKey, ibctransfertypes.StoreKey, packetforwardtypes.StoreKey,
|
|
303
335
|
capabilitytypes.StoreKey, feegrant.StoreKey, authzkeeper.StoreKey, icahosttypes.StoreKey,
|
|
304
|
-
swingset.StoreKey, vstorage.StoreKey, vibc.StoreKey,
|
|
336
|
+
swingset.StoreKey, vstorage.StoreKey, vibc.StoreKey,
|
|
337
|
+
vlocalchain.StoreKey, vtransfer.StoreKey, vbank.StoreKey,
|
|
305
338
|
)
|
|
306
339
|
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
|
|
307
340
|
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
|
308
341
|
|
|
309
342
|
app := &GaiaApp{
|
|
310
343
|
BaseApp: bApp,
|
|
344
|
+
AgdServer: agdServer,
|
|
311
345
|
legacyAmino: legacyAmino,
|
|
312
346
|
appCodec: appCodec,
|
|
313
347
|
interfaceRegistry: interfaceRegistry,
|
|
@@ -326,7 +360,7 @@ func NewAgoricApp(
|
|
|
326
360
|
|
|
327
361
|
// set the BaseApp's parameter store
|
|
328
362
|
bApp.SetParamStore(
|
|
329
|
-
app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(
|
|
363
|
+
app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable()),
|
|
330
364
|
)
|
|
331
365
|
|
|
332
366
|
// add capability keeper and ScopeToModule for ibc module
|
|
@@ -338,15 +372,15 @@ func NewAgoricApp(
|
|
|
338
372
|
app.CapabilityKeeper.Seal()
|
|
339
373
|
|
|
340
374
|
// add keepers
|
|
341
|
-
|
|
375
|
+
app.AccountKeeper = authkeeper.NewAccountKeeper(
|
|
342
376
|
appCodec,
|
|
343
377
|
keys[authtypes.StoreKey],
|
|
344
378
|
app.GetSubspace(authtypes.ModuleName),
|
|
345
379
|
authtypes.ProtoBaseAccount,
|
|
346
380
|
maccPerms,
|
|
381
|
+
appName,
|
|
347
382
|
)
|
|
348
|
-
|
|
349
|
-
app.AccountKeeper = wrappedAccountKeeper
|
|
383
|
+
|
|
350
384
|
app.BankKeeper = bankkeeper.NewBaseKeeper(
|
|
351
385
|
appCodec,
|
|
352
386
|
keys[banktypes.StoreKey],
|
|
@@ -358,6 +392,7 @@ func NewAgoricApp(
|
|
|
358
392
|
keys[authzkeeper.StoreKey],
|
|
359
393
|
appCodec,
|
|
360
394
|
app.BaseApp.MsgServiceRouter(),
|
|
395
|
+
app.AccountKeeper,
|
|
361
396
|
)
|
|
362
397
|
app.FeeGrantKeeper = feegrantkeeper.NewKeeper(
|
|
363
398
|
appCodec,
|
|
@@ -389,7 +424,6 @@ func NewAgoricApp(
|
|
|
389
424
|
&stakingKeeper,
|
|
390
425
|
// This is the pool to distribute from immediately. DO NOT ALTER.
|
|
391
426
|
vbanktypes.GiveawayPoolName,
|
|
392
|
-
app.ModuleAccountAddrs(),
|
|
393
427
|
)
|
|
394
428
|
app.SlashingKeeper = slashingkeeper.NewKeeper(
|
|
395
429
|
appCodec,
|
|
@@ -397,18 +431,13 @@ func NewAgoricApp(
|
|
|
397
431
|
&stakingKeeper,
|
|
398
432
|
app.GetSubspace(slashingtypes.ModuleName),
|
|
399
433
|
)
|
|
400
|
-
app.CrisisKeeper = crisiskeeper.NewKeeper(
|
|
401
|
-
app.GetSubspace(crisistypes.ModuleName),
|
|
402
|
-
invCheckPeriod,
|
|
403
|
-
app.BankKeeper,
|
|
404
|
-
vbanktypes.ReservePoolName,
|
|
405
|
-
)
|
|
406
434
|
app.UpgradeKeeper = upgradekeeper.NewKeeper(
|
|
407
435
|
skipUpgradeHeights,
|
|
408
436
|
keys[upgradetypes.StoreKey],
|
|
409
437
|
appCodec,
|
|
410
438
|
homePath,
|
|
411
439
|
app.BaseApp,
|
|
440
|
+
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
|
|
412
441
|
)
|
|
413
442
|
|
|
414
443
|
// register the staking hooks
|
|
@@ -428,18 +457,21 @@ func NewAgoricApp(
|
|
|
428
457
|
)
|
|
429
458
|
|
|
430
459
|
// This function is tricky to get right, so we build it ourselves.
|
|
431
|
-
callToController := func(ctx sdk.Context,
|
|
460
|
+
callToController := func(ctx sdk.Context, jsonRequest string) (jsonReply string, err error) {
|
|
461
|
+
app.CheckControllerInited(true)
|
|
432
462
|
// We use SwingSet-level metering to charge the user for the call.
|
|
433
|
-
app.
|
|
434
|
-
|
|
435
|
-
|
|
463
|
+
defer app.AgdServer.SetControllerContext(ctx)()
|
|
464
|
+
return sendToController(sdk.WrapSDKContext(ctx), true, jsonRequest)
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
setBootstrapNeeded := func() {
|
|
468
|
+
app.bootstrapNeeded = true
|
|
436
469
|
}
|
|
437
470
|
|
|
438
471
|
app.VstorageKeeper = vstorage.NewKeeper(
|
|
439
472
|
keys[vstorage.StoreKey],
|
|
440
473
|
)
|
|
441
|
-
|
|
442
|
-
app.vstoragePort = vm.GetPort("vstorage")
|
|
474
|
+
app.vstoragePort = app.AgdServer.MustRegisterPortHandler("vstorage", vstorage.NewStorageHandler(app.VstorageKeeper))
|
|
443
475
|
|
|
444
476
|
// The SwingSetKeeper is the Keeper from the SwingSet module
|
|
445
477
|
app.SwingSetKeeper = swingset.NewKeeper(
|
|
@@ -448,24 +480,59 @@ func NewAgoricApp(
|
|
|
448
480
|
app.VstorageKeeper, vbanktypes.ReservePoolName,
|
|
449
481
|
callToController,
|
|
450
482
|
)
|
|
483
|
+
app.swingsetPort = app.AgdServer.MustRegisterPortHandler("swingset", swingset.NewPortHandler(app.SwingSetKeeper))
|
|
484
|
+
|
|
485
|
+
app.SwingStoreExportsHandler = *swingsetkeeper.NewSwingStoreExportsHandler(
|
|
486
|
+
app.Logger(),
|
|
487
|
+
func(action vm.Jsonable, mustNotBeInited bool) (string, error) {
|
|
488
|
+
if mustNotBeInited {
|
|
489
|
+
app.CheckControllerInited(false)
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
bz, err := json.Marshal(action)
|
|
493
|
+
if err != nil {
|
|
494
|
+
return "", err
|
|
495
|
+
}
|
|
496
|
+
return sendToController(context.Background(), true, string(bz))
|
|
497
|
+
},
|
|
498
|
+
)
|
|
451
499
|
|
|
452
|
-
|
|
500
|
+
getSwingStoreExportDataShadowCopyReader := func(height int64) agorictypes.KVEntryReader {
|
|
501
|
+
ctx := app.NewUncachedContext(false, tmproto.Header{Height: height})
|
|
502
|
+
exportDataIterator := app.SwingSetKeeper.GetSwingStore(ctx).Iterator(nil, nil)
|
|
503
|
+
if !exportDataIterator.Valid() {
|
|
504
|
+
exportDataIterator.Close()
|
|
505
|
+
return nil
|
|
506
|
+
}
|
|
507
|
+
return agorictypes.NewKVIteratorReader(exportDataIterator)
|
|
508
|
+
}
|
|
509
|
+
app.SwingSetSnapshotter = *swingsetkeeper.NewExtensionSnapshotter(
|
|
453
510
|
bApp,
|
|
454
|
-
app.
|
|
455
|
-
|
|
511
|
+
&app.SwingStoreExportsHandler,
|
|
512
|
+
getSwingStoreExportDataShadowCopyReader,
|
|
456
513
|
)
|
|
457
514
|
|
|
458
515
|
app.VibcKeeper = vibc.NewKeeper(
|
|
459
|
-
appCodec,
|
|
516
|
+
appCodec,
|
|
460
517
|
app.IBCKeeper.ChannelKeeper, &app.IBCKeeper.PortKeeper,
|
|
461
|
-
|
|
462
|
-
|
|
518
|
+
).WithScope(keys[vibc.StoreKey], scopedVibcKeeper, app.SwingSetKeeper.PushAction)
|
|
519
|
+
|
|
520
|
+
vibcModule := vibc.NewAppModule(app.VibcKeeper, app.BankKeeper)
|
|
521
|
+
vibcIBCModule := vibc.NewIBCModule(app.VibcKeeper)
|
|
522
|
+
app.vibcPort = app.AgdServer.MustRegisterPortHandler("vibc", vibc.NewReceiver(app.VibcKeeper))
|
|
523
|
+
|
|
524
|
+
app.VtransferKeeper = vtransferkeeper.NewKeeper(
|
|
525
|
+
appCodec,
|
|
526
|
+
keys[vtransfer.StoreKey],
|
|
527
|
+
app.VibcKeeper,
|
|
528
|
+
scopedTransferKeeper,
|
|
463
529
|
app.SwingSetKeeper.PushAction,
|
|
464
530
|
)
|
|
465
531
|
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
532
|
+
vtransferModule := vtransfer.NewAppModule(app.VtransferKeeper)
|
|
533
|
+
app.vtransferPort = app.AgdServer.MustRegisterPortHandler("vtransfer",
|
|
534
|
+
vibc.NewReceiver(app.VtransferKeeper),
|
|
535
|
+
)
|
|
469
536
|
|
|
470
537
|
app.VbankKeeper = vbank.NewKeeper(
|
|
471
538
|
appCodec, keys[vbank.StoreKey], app.GetSubspace(vbank.ModuleName),
|
|
@@ -473,27 +540,18 @@ func NewAgoricApp(
|
|
|
473
540
|
app.SwingSetKeeper.PushAction,
|
|
474
541
|
)
|
|
475
542
|
vbankModule := vbank.NewAppModule(app.VbankKeeper)
|
|
476
|
-
app.vbankPort =
|
|
477
|
-
|
|
478
|
-
// Lien keeper, and circular reference back to wrappedAccountKeeper
|
|
479
|
-
app.LienKeeper = lien.NewKeeper(
|
|
480
|
-
appCodec, keys[lien.StoreKey],
|
|
481
|
-
wrappedAccountKeeper, app.BankKeeper, app.StakingKeeper,
|
|
482
|
-
app.SwingSetKeeper.PushAction,
|
|
483
|
-
)
|
|
484
|
-
wrappedAccountKeeper.SetWrapper(app.LienKeeper.GetAccountWrapper())
|
|
485
|
-
lienModule := lien.NewAppModule(app.LienKeeper)
|
|
486
|
-
app.lienPort = vm.RegisterPortHandler("lien", lien.NewPortHandler(app.LienKeeper))
|
|
543
|
+
app.vbankPort = app.AgdServer.MustRegisterPortHandler("bank", vbank.NewPortHandler(vbankModule, app.VbankKeeper))
|
|
487
544
|
|
|
488
545
|
// register the proposal types
|
|
489
|
-
govRouter :=
|
|
546
|
+
govRouter := govv1beta1.NewRouter()
|
|
490
547
|
govRouter.
|
|
491
|
-
AddRoute(govtypes.RouterKey,
|
|
548
|
+
AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler).
|
|
492
549
|
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
|
|
493
550
|
AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)).
|
|
494
551
|
AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)).
|
|
495
552
|
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
|
|
496
553
|
AddRoute(swingsettypes.RouterKey, swingset.NewSwingSetProposalHandler(app.SwingSetKeeper))
|
|
554
|
+
govConfig := govtypes.DefaultConfig()
|
|
497
555
|
|
|
498
556
|
app.GovKeeper = govkeeper.NewKeeper(
|
|
499
557
|
appCodec,
|
|
@@ -503,43 +561,95 @@ func NewAgoricApp(
|
|
|
503
561
|
app.BankKeeper,
|
|
504
562
|
&stakingKeeper,
|
|
505
563
|
govRouter,
|
|
564
|
+
app.BaseApp.MsgServiceRouter(),
|
|
565
|
+
govConfig,
|
|
566
|
+
)
|
|
567
|
+
|
|
568
|
+
// Initialize the packet forward middleware Keeper
|
|
569
|
+
// It's important to note that the PFM Keeper must be initialized before the Transfer Keeper
|
|
570
|
+
app.PacketForwardKeeper = packetforwardkeeper.NewKeeper(
|
|
571
|
+
appCodec,
|
|
572
|
+
keys[packetforwardtypes.StoreKey],
|
|
573
|
+
app.GetSubspace(packetforwardtypes.ModuleName),
|
|
574
|
+
app.TransferKeeper, // will be zero-value here, reference is set later on with SetTransferKeeper.
|
|
575
|
+
app.IBCKeeper.ChannelKeeper,
|
|
576
|
+
app.DistrKeeper,
|
|
577
|
+
app.BankKeeper,
|
|
578
|
+
// Make vtransfer the middleware wrapper for the IBCKeeper.
|
|
579
|
+
app.VtransferKeeper.GetICS4Wrapper(),
|
|
506
580
|
)
|
|
507
581
|
|
|
508
582
|
app.TransferKeeper = ibctransferkeeper.NewKeeper(
|
|
509
583
|
appCodec,
|
|
510
584
|
keys[ibctransfertypes.StoreKey],
|
|
511
585
|
app.GetSubspace(ibctransfertypes.ModuleName),
|
|
512
|
-
app.
|
|
586
|
+
app.PacketForwardKeeper, // Wire in the middleware ICS4Wrapper.
|
|
513
587
|
app.IBCKeeper.ChannelKeeper,
|
|
514
588
|
&app.IBCKeeper.PortKeeper,
|
|
515
589
|
app.AccountKeeper,
|
|
516
590
|
app.BankKeeper,
|
|
517
591
|
scopedTransferKeeper,
|
|
518
592
|
)
|
|
519
|
-
transferModule := transfer.NewAppModule(app.TransferKeeper)
|
|
520
|
-
transferIBCModule := transfer.NewIBCModule(app.TransferKeeper)
|
|
521
593
|
|
|
594
|
+
app.PacketForwardKeeper.SetTransferKeeper(app.TransferKeeper)
|
|
595
|
+
|
|
596
|
+
// NewAppModule uses a pointer to the host keeper in case there's a need to
|
|
597
|
+
// tie a circular knot with IBC middleware before icahostkeeper.NewKeeper
|
|
598
|
+
// can be called.
|
|
522
599
|
app.ICAHostKeeper = icahostkeeper.NewKeeper(
|
|
523
600
|
appCodec, keys[icahosttypes.StoreKey],
|
|
524
601
|
app.GetSubspace(icahosttypes.SubModuleName),
|
|
602
|
+
app.IBCKeeper.ChannelKeeper, // This is where middleware binding would happen.
|
|
525
603
|
app.IBCKeeper.ChannelKeeper,
|
|
526
604
|
&app.IBCKeeper.PortKeeper,
|
|
527
605
|
app.AccountKeeper,
|
|
528
606
|
scopedICAHostKeeper,
|
|
529
607
|
app.MsgServiceRouter(),
|
|
530
608
|
)
|
|
531
|
-
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
|
|
532
609
|
icaHostIBCModule := icahost.NewIBCModule(app.ICAHostKeeper)
|
|
610
|
+
icaModule := ica.NewAppModule(nil, &app.ICAHostKeeper)
|
|
611
|
+
|
|
612
|
+
ics20TransferModule := ibctransfer.NewAppModule(app.TransferKeeper)
|
|
533
613
|
|
|
534
|
-
//
|
|
535
|
-
|
|
536
|
-
ibcRouter := porttypes.NewRouter()
|
|
537
|
-
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule).
|
|
538
|
-
AddRoute(ibctransfertypes.ModuleName, transferIBCModule).
|
|
539
|
-
AddRoute(vibc.ModuleName, vibcIBCModule)
|
|
614
|
+
// Create the IBC router, which maps *module names* (not PortIDs) to modules.
|
|
615
|
+
ibcRouter := ibcporttypes.NewRouter()
|
|
540
616
|
|
|
617
|
+
// Add an IBC route for the ICA Host.
|
|
618
|
+
ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule)
|
|
619
|
+
|
|
620
|
+
// Add an IBC route for vIBC.
|
|
621
|
+
ibcRouter.AddRoute(vibc.ModuleName, vibcIBCModule)
|
|
622
|
+
|
|
623
|
+
// Add an IBC route for ICS-20 fungible token transfers, wrapping base
|
|
624
|
+
// Cosmos functionality with middleware (from the inside out, Cosmos
|
|
625
|
+
// packet-forwarding and then our own "vtransfer").
|
|
626
|
+
var ics20TransferIBCModule ibcporttypes.IBCModule = ibctransfer.NewIBCModule(app.TransferKeeper)
|
|
627
|
+
ics20TransferIBCModule = packetforward.NewIBCMiddleware(
|
|
628
|
+
ics20TransferIBCModule,
|
|
629
|
+
app.PacketForwardKeeper,
|
|
630
|
+
0, // retries on timeout
|
|
631
|
+
packetforwardkeeper.DefaultForwardTransferPacketTimeoutTimestamp, // forward timeout
|
|
632
|
+
packetforwardkeeper.DefaultRefundTransferPacketTimeoutTimestamp, // refund timeout
|
|
633
|
+
)
|
|
634
|
+
ics20TransferIBCModule = vtransfer.NewIBCMiddleware(ics20TransferIBCModule, app.VtransferKeeper)
|
|
635
|
+
ibcRouter.AddRoute(ibctransfertypes.ModuleName, ics20TransferIBCModule)
|
|
636
|
+
|
|
637
|
+
// Seal the router
|
|
541
638
|
app.IBCKeeper.SetRouter(ibcRouter)
|
|
542
639
|
|
|
640
|
+
// The local chain keeper provides ICA/ICQ-like support for the VM to
|
|
641
|
+
// control a fresh account and/or query this Cosmos-SDK instance.
|
|
642
|
+
app.VlocalchainKeeper = vlocalchain.NewKeeper(
|
|
643
|
+
appCodec,
|
|
644
|
+
keys[vlocalchain.StoreKey],
|
|
645
|
+
app.BaseApp.MsgServiceRouter(),
|
|
646
|
+
app.BaseApp.GRPCQueryRouter(),
|
|
647
|
+
)
|
|
648
|
+
app.vlocalchainPort = app.AgdServer.MustRegisterPortHandler(
|
|
649
|
+
"vlocalchain",
|
|
650
|
+
vlocalchain.NewReceiver(app.VlocalchainKeeper),
|
|
651
|
+
)
|
|
652
|
+
|
|
543
653
|
// create evidence keeper with router
|
|
544
654
|
evidenceKeeper := evidencekeeper.NewKeeper(
|
|
545
655
|
appCodec,
|
|
@@ -550,7 +660,7 @@ func NewAgoricApp(
|
|
|
550
660
|
|
|
551
661
|
app.EvidenceKeeper = *evidenceKeeper
|
|
552
662
|
|
|
553
|
-
|
|
663
|
+
swingStoreExportDir := cast.ToString(appOpts.Get(FlagSwingStoreExportDir))
|
|
554
664
|
|
|
555
665
|
// NOTE: Any module instantiated in the module manager that is later modified
|
|
556
666
|
// must be passed by reference here.
|
|
@@ -565,9 +675,8 @@ func NewAgoricApp(
|
|
|
565
675
|
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
566
676
|
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
|
|
567
677
|
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
|
|
568
|
-
crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants),
|
|
569
678
|
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
|
570
|
-
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
|
|
679
|
+
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
|
|
571
680
|
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
572
681
|
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
573
682
|
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
|
@@ -577,13 +686,14 @@ func NewAgoricApp(
|
|
|
577
686
|
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
|
|
578
687
|
ibc.NewAppModule(app.IBCKeeper),
|
|
579
688
|
params.NewAppModule(app.ParamsKeeper),
|
|
580
|
-
|
|
689
|
+
ics20TransferModule,
|
|
581
690
|
icaModule,
|
|
691
|
+
packetforward.NewAppModule(app.PacketForwardKeeper),
|
|
582
692
|
vstorage.NewAppModule(app.VstorageKeeper),
|
|
583
|
-
swingset.NewAppModule(app.SwingSetKeeper),
|
|
693
|
+
swingset.NewAppModule(app.SwingSetKeeper, &app.SwingStoreExportsHandler, setBootstrapNeeded, app.ensureControllerInited, swingStoreExportDir),
|
|
584
694
|
vibcModule,
|
|
585
695
|
vbankModule,
|
|
586
|
-
|
|
696
|
+
vtransferModule,
|
|
587
697
|
)
|
|
588
698
|
|
|
589
699
|
// During begin block slashing happens after distr.BeginBlocker so that
|
|
@@ -592,15 +702,19 @@ func NewAgoricApp(
|
|
|
592
702
|
// NOTE: staking module is required if HistoricalEntries param > 0
|
|
593
703
|
// NOTE: capability module's beginblocker must come before any modules using capabilities (e.g. IBC)
|
|
594
704
|
app.mm.SetOrderBeginBlockers(
|
|
705
|
+
// Cosmos-SDK modules appear roughly in the order used by simapp and gaiad.
|
|
595
706
|
// upgrades should be run first
|
|
596
707
|
upgradetypes.ModuleName,
|
|
597
708
|
capabilitytypes.ModuleName,
|
|
598
|
-
|
|
709
|
+
// params influence many other modules, so it should be near the top.
|
|
710
|
+
paramstypes.ModuleName,
|
|
599
711
|
govtypes.ModuleName,
|
|
600
712
|
stakingtypes.ModuleName,
|
|
713
|
+
// ibc apps are grouped together
|
|
601
714
|
ibctransfertypes.ModuleName,
|
|
602
715
|
ibchost.ModuleName,
|
|
603
716
|
icatypes.ModuleName,
|
|
717
|
+
packetforwardtypes.ModuleName,
|
|
604
718
|
authtypes.ModuleName,
|
|
605
719
|
banktypes.ModuleName,
|
|
606
720
|
distrtypes.ModuleName,
|
|
@@ -610,24 +724,26 @@ func NewAgoricApp(
|
|
|
610
724
|
evidencetypes.ModuleName,
|
|
611
725
|
authz.ModuleName,
|
|
612
726
|
feegrant.ModuleName,
|
|
613
|
-
paramstypes.ModuleName,
|
|
614
727
|
vestingtypes.ModuleName,
|
|
615
728
|
vstorage.ModuleName,
|
|
729
|
+
// This will cause the swingset controller to init if it hadn't yet, passing
|
|
730
|
+
// any upgrade plan or bootstrap flag when starting at an upgrade height
|
|
616
731
|
swingset.ModuleName,
|
|
617
732
|
vibc.ModuleName,
|
|
618
733
|
vbank.ModuleName,
|
|
619
|
-
|
|
734
|
+
vtransfer.ModuleName,
|
|
620
735
|
)
|
|
621
736
|
app.mm.SetOrderEndBlockers(
|
|
622
|
-
|
|
623
|
-
vbank.ModuleName,
|
|
624
|
-
lien.ModuleName,
|
|
625
|
-
crisistypes.ModuleName,
|
|
737
|
+
// Cosmos-SDK modules appear roughly in the order used by simapp and gaiad.
|
|
626
738
|
govtypes.ModuleName,
|
|
627
739
|
stakingtypes.ModuleName,
|
|
740
|
+
// vibc is an Agoric-specific IBC app, so group it here with other IBC apps.
|
|
741
|
+
vibc.ModuleName,
|
|
742
|
+
vtransfer.ModuleName,
|
|
628
743
|
ibctransfertypes.ModuleName,
|
|
629
744
|
ibchost.ModuleName,
|
|
630
745
|
icatypes.ModuleName,
|
|
746
|
+
packetforwardtypes.ModuleName,
|
|
631
747
|
feegrant.ModuleName,
|
|
632
748
|
authz.ModuleName,
|
|
633
749
|
capabilitytypes.ModuleName,
|
|
@@ -641,7 +757,11 @@ func NewAgoricApp(
|
|
|
641
757
|
paramstypes.ModuleName,
|
|
642
758
|
upgradetypes.ModuleName,
|
|
643
759
|
vestingtypes.ModuleName,
|
|
644
|
-
//
|
|
760
|
+
// Putting vbank before SwingSet VM will enable vbank to capture all event
|
|
761
|
+
// history that was produced all the other modules, and push those balance
|
|
762
|
+
// changes on the VM's actionQueue.
|
|
763
|
+
vbank.ModuleName,
|
|
764
|
+
// SwingSet VM needs to be last, for it to capture all the pushed actions.
|
|
645
765
|
swingset.ModuleName,
|
|
646
766
|
// And then vstorage, to produce SwingSet-induced events.
|
|
647
767
|
vstorage.ModuleName,
|
|
@@ -658,33 +778,33 @@ func NewAgoricApp(
|
|
|
658
778
|
capabilitytypes.ModuleName,
|
|
659
779
|
authtypes.ModuleName,
|
|
660
780
|
banktypes.ModuleName,
|
|
781
|
+
paramstypes.ModuleName,
|
|
661
782
|
distrtypes.ModuleName,
|
|
662
783
|
stakingtypes.ModuleName,
|
|
663
784
|
slashingtypes.ModuleName,
|
|
664
785
|
govtypes.ModuleName,
|
|
665
786
|
minttypes.ModuleName,
|
|
666
|
-
crisistypes.ModuleName,
|
|
667
787
|
ibctransfertypes.ModuleName,
|
|
788
|
+
packetforwardtypes.ModuleName,
|
|
668
789
|
ibchost.ModuleName,
|
|
669
790
|
icatypes.ModuleName,
|
|
670
791
|
evidencetypes.ModuleName,
|
|
671
792
|
feegrant.ModuleName,
|
|
672
793
|
authz.ModuleName,
|
|
673
794
|
genutiltypes.ModuleName,
|
|
674
|
-
paramstypes.ModuleName,
|
|
675
795
|
upgradetypes.ModuleName,
|
|
676
796
|
vestingtypes.ModuleName,
|
|
797
|
+
// Agoric-specific modules go last since they may rely on other SDK modules.
|
|
677
798
|
vstorage.ModuleName,
|
|
678
799
|
vbank.ModuleName,
|
|
679
800
|
vibc.ModuleName,
|
|
801
|
+
vtransfer.ModuleName,
|
|
680
802
|
swingset.ModuleName,
|
|
681
|
-
lien.ModuleName,
|
|
682
803
|
}
|
|
683
804
|
|
|
684
805
|
app.mm.SetOrderInitGenesis(moduleOrderForGenesisAndUpgrade...)
|
|
685
806
|
app.mm.SetOrderMigrations(moduleOrderForGenesisAndUpgrade...)
|
|
686
807
|
|
|
687
|
-
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
|
688
808
|
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
|
|
689
809
|
|
|
690
810
|
app.configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
|
|
@@ -701,14 +821,14 @@ func NewAgoricApp(
|
|
|
701
821
|
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
|
|
702
822
|
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
|
|
703
823
|
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
|
|
704
|
-
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper),
|
|
824
|
+
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil),
|
|
705
825
|
staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper),
|
|
706
826
|
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
707
827
|
slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
|
|
708
828
|
params.NewAppModule(app.ParamsKeeper),
|
|
709
829
|
evidence.NewAppModule(app.EvidenceKeeper),
|
|
710
830
|
ibc.NewAppModule(app.IBCKeeper),
|
|
711
|
-
|
|
831
|
+
ics20TransferModule,
|
|
712
832
|
)
|
|
713
833
|
|
|
714
834
|
app.sm.RegisterStoreDecoders()
|
|
@@ -742,14 +862,32 @@ func NewAgoricApp(
|
|
|
742
862
|
app.SetBeginBlocker(app.BeginBlocker)
|
|
743
863
|
app.SetEndBlocker(app.EndBlocker)
|
|
744
864
|
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
)
|
|
865
|
+
for name := range upgradeNamesOfThisVersion {
|
|
866
|
+
app.UpgradeKeeper.SetUpgradeHandler(
|
|
867
|
+
name,
|
|
868
|
+
unreleasedUpgradeHandler(app, name),
|
|
869
|
+
)
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
|
|
873
|
+
if err != nil {
|
|
874
|
+
panic(err)
|
|
875
|
+
}
|
|
876
|
+
if upgradeNamesOfThisVersion[upgradeInfo.Name] && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
|
877
|
+
storeUpgrades := storetypes.StoreUpgrades{
|
|
878
|
+
Added: []string{
|
|
879
|
+
packetforwardtypes.ModuleName, // Added PFM
|
|
880
|
+
vlocalchain.ModuleName, // Agoric added vlocalchain
|
|
881
|
+
vtransfer.ModuleName, // Agoric added vtransfer
|
|
882
|
+
},
|
|
883
|
+
Deleted: []string{
|
|
884
|
+
"lien", // Agoric removed the lien module
|
|
885
|
+
},
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// configure store loader that checks if version == upgradeHeight and applies store upgrades
|
|
889
|
+
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
|
|
890
|
+
}
|
|
753
891
|
|
|
754
892
|
if loadLatest {
|
|
755
893
|
if err := app.LoadLatestVersion(); err != nil {
|
|
@@ -771,42 +909,6 @@ func NewAgoricApp(
|
|
|
771
909
|
return app
|
|
772
910
|
}
|
|
773
911
|
|
|
774
|
-
func upgrade10Handler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
775
|
-
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
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
912
|
// normalizeModuleAccount ensures that the given account is a module account,
|
|
811
913
|
// initializing or updating it if necessary. The account name must be listed in maccPerms.
|
|
812
914
|
func normalizeModuleAccount(ctx sdk.Context, ak authkeeper.AccountKeeper, name string) {
|
|
@@ -824,56 +926,101 @@ func normalizeModuleAccount(ctx sdk.Context, ak authkeeper.AccountKeeper, name s
|
|
|
824
926
|
ak.SetModuleAccount(ctx, newAcct)
|
|
825
927
|
}
|
|
826
928
|
|
|
929
|
+
type upgradeDetails struct {
|
|
930
|
+
Plan upgradetypes.Plan `json:"plan"`
|
|
931
|
+
CoreProposals *vm.CoreProposals `json:"coreProposals,omitempty"`
|
|
932
|
+
}
|
|
933
|
+
|
|
827
934
|
type cosmosInitAction struct {
|
|
828
|
-
|
|
829
|
-
ChainID
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
935
|
+
vm.ActionHeader `actionType:"AG_COSMOS_INIT"`
|
|
936
|
+
ChainID string `json:"chainID"`
|
|
937
|
+
IsBootstrap bool `json:"isBootstrap"`
|
|
938
|
+
UpgradeDetails *upgradeDetails `json:"upgradeDetails,omitempty"`
|
|
939
|
+
Params swingset.Params `json:"params"`
|
|
940
|
+
SupplyCoins sdk.Coins `json:"supplyCoins"`
|
|
941
|
+
// CAVEAT: Every property ending in "Port" is saved in chain-main.js/portNums
|
|
942
|
+
// with a key consisting of this name with the "Port" stripped.
|
|
943
|
+
StoragePort int `json:"storagePort"`
|
|
944
|
+
SwingsetPort int `json:"swingsetPort"`
|
|
945
|
+
VbankPort int `json:"vbankPort"`
|
|
946
|
+
VibcPort int `json:"vibcPort"`
|
|
947
|
+
VlocalchainPort int `json:"vlocalchainPort"`
|
|
948
|
+
VtransferPort int `json:"vtransferPort"`
|
|
836
949
|
}
|
|
837
950
|
|
|
838
951
|
// Name returns the name of the App
|
|
839
952
|
func (app *GaiaApp) Name() string { return app.BaseApp.Name() }
|
|
840
953
|
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
954
|
+
// CheckControllerInited exits if the controller initialization state does not match `expected`.
|
|
955
|
+
func (app *GaiaApp) CheckControllerInited(expected bool) {
|
|
956
|
+
if app.controllerInited != expected {
|
|
957
|
+
fmt.Fprintf(os.Stderr, "controllerInited != %t\n", expected)
|
|
958
|
+
debug.PrintStack()
|
|
959
|
+
os.Exit(1)
|
|
844
960
|
}
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// initController sends the initialization message to the VM.
|
|
964
|
+
// Exits if the controller has already been initialized.
|
|
965
|
+
// The init message will contain any upgrade plan if we're starting after an
|
|
966
|
+
// upgrade, and a flag indicating whether this is a bootstrap of the controller.
|
|
967
|
+
func (app *GaiaApp) initController(ctx sdk.Context, bootstrap bool) {
|
|
968
|
+
app.CheckControllerInited(false)
|
|
845
969
|
app.controllerInited = true
|
|
970
|
+
|
|
846
971
|
// Begin initializing the controller here.
|
|
847
972
|
action := &cosmosInitAction{
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
Params:
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
973
|
+
ChainID: ctx.ChainID(),
|
|
974
|
+
IsBootstrap: bootstrap,
|
|
975
|
+
Params: app.SwingSetKeeper.GetParams(ctx),
|
|
976
|
+
SupplyCoins: sdk.NewCoins(app.BankKeeper.GetSupply(ctx, "uist")),
|
|
977
|
+
UpgradeDetails: app.upgradeDetails,
|
|
978
|
+
// See CAVEAT in cosmosInitAction.
|
|
979
|
+
StoragePort: app.vstoragePort,
|
|
980
|
+
SwingsetPort: app.swingsetPort,
|
|
981
|
+
VbankPort: app.vbankPort,
|
|
982
|
+
VibcPort: app.vibcPort,
|
|
983
|
+
VlocalchainPort: app.vlocalchainPort,
|
|
984
|
+
VtransferPort: app.vtransferPort,
|
|
856
985
|
}
|
|
986
|
+
// This uses `BlockingSend` as a friendly wrapper for `sendToController`
|
|
987
|
+
//
|
|
988
|
+
// CAVEAT: we are restarting after an in-consensus halt or just because this
|
|
989
|
+
// node felt like it. The controller must be able to handle either case
|
|
990
|
+
// (inConsensus := action.IsBootstrap || action.UpgradeDetails != nil).
|
|
857
991
|
out, err := app.SwingSetKeeper.BlockingSend(ctx, action)
|
|
858
992
|
|
|
859
993
|
// fmt.Fprintf(os.Stderr, "AG_COSMOS_INIT Returned from SwingSet: %s, %v\n", out, err)
|
|
860
994
|
|
|
861
995
|
if err != nil {
|
|
862
|
-
|
|
863
|
-
os.Exit(1)
|
|
996
|
+
panic(sdkioerrors.Wrap(err, "cannot initialize Controller"))
|
|
864
997
|
}
|
|
865
998
|
var res bool
|
|
866
999
|
err = json.Unmarshal([]byte(out), &res)
|
|
867
1000
|
if err != nil {
|
|
868
|
-
|
|
869
|
-
os.Exit(1)
|
|
1001
|
+
panic(sdkioerrors.Wrapf(err, "cannot unmarshal Controller init response: %s", out))
|
|
870
1002
|
}
|
|
871
1003
|
if !res {
|
|
872
|
-
fmt.
|
|
873
|
-
os.Exit(1)
|
|
1004
|
+
panic(fmt.Errorf("controller negative init response"))
|
|
874
1005
|
}
|
|
875
1006
|
}
|
|
876
1007
|
|
|
1008
|
+
// ensureControllerInited inits the controller if needed. It's used by the
|
|
1009
|
+
// x/swingset module's BeginBlock to lazily start the JS controller.
|
|
1010
|
+
// We cannot init early as we don't know when starting the software if this
|
|
1011
|
+
// might be a simple restart, or a chain init from genesis or upgrade which
|
|
1012
|
+
// require the controller to not be inited yet.
|
|
1013
|
+
func (app *GaiaApp) ensureControllerInited(ctx sdk.Context) {
|
|
1014
|
+
if app.controllerInited {
|
|
1015
|
+
return
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// While we don't expect it anymore, some upgrade may want to throw away
|
|
1019
|
+
// the current JS state and bootstrap again (bulldozer). In that case the
|
|
1020
|
+
// upgrade handler can just set the bootstrapNeeded flag.
|
|
1021
|
+
app.initController(ctx, app.bootstrapNeeded)
|
|
1022
|
+
}
|
|
1023
|
+
|
|
877
1024
|
// BeginBlocker application updates every begin block
|
|
878
1025
|
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
|
|
879
1026
|
return app.mm.BeginBlock(ctx, req)
|
|
@@ -894,6 +1041,16 @@ func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
|
|
894
1041
|
app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap())
|
|
895
1042
|
res := app.mm.InitGenesis(ctx, app.appCodec, genesisState)
|
|
896
1043
|
|
|
1044
|
+
// initialize the provision and reserve module accounts, to avoid their implicit creation
|
|
1045
|
+
// as a default account upon receiving a transfer. See BlockedAddrs().
|
|
1046
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ProvisionPoolName)
|
|
1047
|
+
normalizeModuleAccount(ctx, app.AccountKeeper, vbanktypes.ReservePoolName)
|
|
1048
|
+
|
|
1049
|
+
// Init early (before first BeginBlock) to run the potentially lengthy bootstrap
|
|
1050
|
+
if app.bootstrapNeeded {
|
|
1051
|
+
app.initController(ctx, true)
|
|
1052
|
+
}
|
|
1053
|
+
|
|
897
1054
|
// Agoric: report the genesis time explicitly.
|
|
898
1055
|
genTime := req.GetTime()
|
|
899
1056
|
if genTime.After(time.Now()) {
|
|
@@ -901,20 +1058,15 @@ func (app *GaiaApp) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci
|
|
|
901
1058
|
stdlog.Printf("Genesis time %s is in %s\n", genTime, d)
|
|
902
1059
|
}
|
|
903
1060
|
|
|
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
|
-
|
|
909
1061
|
return res
|
|
910
1062
|
}
|
|
911
1063
|
|
|
912
1064
|
// Commit tells the controller that the block is commited
|
|
913
1065
|
func (app *GaiaApp) Commit() abci.ResponseCommit {
|
|
914
|
-
err :=
|
|
1066
|
+
err := swingsetkeeper.WaitUntilSwingStoreExportStarted()
|
|
915
1067
|
|
|
916
1068
|
if err != nil {
|
|
917
|
-
app.Logger().Error("
|
|
1069
|
+
app.Logger().Error("swing-store export failed to start", "err", err)
|
|
918
1070
|
}
|
|
919
1071
|
|
|
920
1072
|
// Frontrun the BaseApp's Commit method
|
|
@@ -999,21 +1151,21 @@ func (app *GaiaApp) InterfaceRegistry() types.InterfaceRegistry {
|
|
|
999
1151
|
// GetKey returns the KVStoreKey for the provided store key.
|
|
1000
1152
|
//
|
|
1001
1153
|
// NOTE: This is solely to be used for testing purposes.
|
|
1002
|
-
func (app *GaiaApp) GetKey(storeKey string) *
|
|
1154
|
+
func (app *GaiaApp) GetKey(storeKey string) *storetypes.KVStoreKey {
|
|
1003
1155
|
return app.keys[storeKey]
|
|
1004
1156
|
}
|
|
1005
1157
|
|
|
1006
1158
|
// GetTKey returns the TransientStoreKey for the provided store key.
|
|
1007
1159
|
//
|
|
1008
1160
|
// NOTE: This is solely to be used for testing purposes.
|
|
1009
|
-
func (app *GaiaApp) GetTKey(storeKey string) *
|
|
1161
|
+
func (app *GaiaApp) GetTKey(storeKey string) *storetypes.TransientStoreKey {
|
|
1010
1162
|
return app.tkeys[storeKey]
|
|
1011
1163
|
}
|
|
1012
1164
|
|
|
1013
1165
|
// GetMemKey returns the MemStoreKey for the provided mem key.
|
|
1014
1166
|
//
|
|
1015
1167
|
// NOTE: This is solely used for testing purposes.
|
|
1016
|
-
func (app *GaiaApp) GetMemKey(storeKey string) *
|
|
1168
|
+
func (app *GaiaApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey {
|
|
1017
1169
|
return app.memKeys[storeKey]
|
|
1018
1170
|
}
|
|
1019
1171
|
|
|
@@ -1034,16 +1186,16 @@ func (app *GaiaApp) SimulationManager() *module.SimulationManager {
|
|
|
1034
1186
|
// API server.
|
|
1035
1187
|
func (app *GaiaApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
|
|
1036
1188
|
clientCtx := apiSvr.ClientCtx
|
|
1037
|
-
rpc.RegisterRoutes(clientCtx, apiSvr.Router)
|
|
1038
|
-
// Register legacy tx routes.
|
|
1039
|
-
authrest.RegisterTxRoutes(clientCtx, apiSvr.Router)
|
|
1040
1189
|
// Register new tx routes from grpc-gateway.
|
|
1041
1190
|
authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
1191
|
+
|
|
1042
1192
|
// Register new tendermint queries routes from grpc-gateway.
|
|
1043
1193
|
tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
1044
1194
|
|
|
1045
|
-
// Register
|
|
1046
|
-
|
|
1195
|
+
// Register node gRPC service for grpc-gateway.
|
|
1196
|
+
nodeservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
1197
|
+
|
|
1198
|
+
// Register grpc-gateway routes for all modules.
|
|
1047
1199
|
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
|
|
1048
1200
|
|
|
1049
1201
|
// register swagger API from root so that other applications can override easily
|
|
@@ -1059,7 +1211,7 @@ func (app *GaiaApp) RegisterTxService(clientCtx client.Context) {
|
|
|
1059
1211
|
|
|
1060
1212
|
// RegisterTendermintService implements the Application.RegisterTendermintService method.
|
|
1061
1213
|
func (app *GaiaApp) RegisterTendermintService(clientCtx client.Context) {
|
|
1062
|
-
tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(),
|
|
1214
|
+
tmservice.RegisterTendermintService(clientCtx, app.BaseApp.GRPCQueryRouter(), app.interfaceRegistry, app.Query)
|
|
1063
1215
|
}
|
|
1064
1216
|
|
|
1065
1217
|
// RegisterSwaggerAPI registers swagger route with API Server
|
|
@@ -1083,7 +1235,7 @@ func GetMaccPerms() map[string][]string {
|
|
|
1083
1235
|
}
|
|
1084
1236
|
|
|
1085
1237
|
// initParamsKeeper init params keeper and its subspaces
|
|
1086
|
-
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey
|
|
1238
|
+
func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper {
|
|
1087
1239
|
paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey)
|
|
1088
1240
|
|
|
1089
1241
|
paramsKeeper.Subspace(authtypes.ModuleName)
|
|
@@ -1092,9 +1244,9 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
|
|
|
1092
1244
|
paramsKeeper.Subspace(minttypes.ModuleName)
|
|
1093
1245
|
paramsKeeper.Subspace(distrtypes.ModuleName)
|
|
1094
1246
|
paramsKeeper.Subspace(slashingtypes.ModuleName)
|
|
1095
|
-
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(
|
|
1096
|
-
paramsKeeper.Subspace(crisistypes.ModuleName)
|
|
1247
|
+
paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypesv1.ParamKeyTable())
|
|
1097
1248
|
paramsKeeper.Subspace(ibctransfertypes.ModuleName)
|
|
1249
|
+
paramsKeeper.Subspace(packetforwardtypes.ModuleName).WithKeyTable(packetforwardtypes.ParamKeyTable())
|
|
1098
1250
|
paramsKeeper.Subspace(ibchost.ModuleName)
|
|
1099
1251
|
paramsKeeper.Subspace(icahosttypes.SubModuleName)
|
|
1100
1252
|
paramsKeeper.Subspace(swingset.ModuleName)
|
|
@@ -1102,3 +1254,36 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
|
|
|
1102
1254
|
|
|
1103
1255
|
return paramsKeeper
|
|
1104
1256
|
}
|
|
1257
|
+
|
|
1258
|
+
// TestingApp functions
|
|
1259
|
+
|
|
1260
|
+
// GetBaseApp implements the TestingApp interface.
|
|
1261
|
+
func (app *GaiaApp) GetBaseApp() *baseapp.BaseApp {
|
|
1262
|
+
return app.BaseApp
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
// GetStakingKeeper implements the TestingApp interface.
|
|
1266
|
+
func (app *GaiaApp) GetStakingKeeper() testtypes.StakingKeeper {
|
|
1267
|
+
return app.StakingKeeper
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1270
|
+
// GetIBCKeeper implements the TestingApp interface.
|
|
1271
|
+
func (app *GaiaApp) GetIBCKeeper() *ibckeeper.Keeper {
|
|
1272
|
+
return app.IBCKeeper
|
|
1273
|
+
}
|
|
1274
|
+
|
|
1275
|
+
// GetScopedIBCKeeper implements the TestingApp interface.
|
|
1276
|
+
func (app *GaiaApp) GetScopedIBCKeeper() capabilitykeeper.ScopedKeeper {
|
|
1277
|
+
return app.ScopedIBCKeeper
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// GetTxConfig implements the TestingApp interface.
|
|
1281
|
+
func (app *GaiaApp) GetTxConfig() client.TxConfig {
|
|
1282
|
+
return MakeEncodingConfig().TxConfig
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
// For testing purposes
|
|
1286
|
+
func (app *GaiaApp) SetSwingStoreExportDir(dir string) {
|
|
1287
|
+
module := app.mm.Modules[swingset.ModuleName].(swingset.AppModule)
|
|
1288
|
+
module.SetSwingStoreExportDir(dir)
|
|
1289
|
+
}
|