@agoric/cosmos 0.34.2-orchestration-dev-096c4e8.0 → 0.34.2-upgrade-16-dev-8879538.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 +29 -26
- package/ante/ante.go +1 -4
- package/app/app.go +69 -39
- package/cmd/agd/main.go +6 -7
- package/cmd/libdaemon/main.go +8 -8
- package/daemon/cmd/root.go +16 -10
- package/daemon/cmd/root_test.go +189 -1
- package/git-revision.txt +1 -1
- package/go.mod +8 -8
- package/go.sum +15 -14
- package/package.json +4 -3
- package/proto/agoric/swingset/swingset.proto +1 -1
- package/scripts/protocgen.sh +7 -8
- package/upgradegaia.sh +8 -8
- package/vm/client_test.go +29 -29
- package/vm/controller.go +0 -38
- package/vm/server.go +106 -5
- package/x/swingset/genesis.go +2 -3
- package/x/swingset/keeper/extension_snapshotter.go +2 -2
- package/x/swingset/module.go +0 -5
- package/x/swingset/types/swingset.pb.go +1 -1
- package/x/vbank/module.go +0 -5
- package/x/vibc/module.go +2 -7
- package/x/vibc/types/ibc_module.go +3 -2
- package/x/vlocalchain/vlocalchain.go +1 -1
- package/x/vlocalchain/vlocalchain_test.go +1 -1
- package/x/vstorage/keeper/grpc_query.go +0 -1
- package/x/vstorage/keeper/keeper.go +4 -12
- package/x/vstorage/module.go +0 -5
- package/ante/fee.go +0 -97
package/MAINTAINERS.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
When updating the protos here, be mindful that `@agoric/cosmic-proto` will need refreshing to get them.
|
|
2
|
+
|
|
3
|
+
https://github.com/Agoric/agoric-sdk/issues/8131 will help automate updating protos, but not the publishing to NPM of the codegen-ed JS utilities for working with the APIs they define.
|
package/Makefile
CHANGED
|
@@ -98,11 +98,11 @@ proto-lint: proto-tools
|
|
|
98
98
|
proto-check-breaking: proto-tools
|
|
99
99
|
${BIN}/buf breaking --against $(PR_TARGET_REPO)#branch=$(PR_TARGET_BRANCH),subdir=golang/cosmos
|
|
100
100
|
|
|
101
|
-
GOGO_PROTO_URL
|
|
102
|
-
# GOOGLE_API_URL
|
|
103
|
-
IBC_PROTO_URL
|
|
104
|
-
COSMOS_PROTO_PROTO_URL
|
|
105
|
-
COSMOS_SDK_PROTO_URL
|
|
101
|
+
GOGO_PROTO_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/gogo/protobuf)
|
|
102
|
+
# GOOGLE_API_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/googleapis/googleapis)/google/api
|
|
103
|
+
IBC_PROTO_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/cosmos/ibc-go/v6)/proto/ibc/core
|
|
104
|
+
COSMOS_PROTO_PROTO_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/cosmos/cosmos-proto)/proto/cosmos_proto
|
|
105
|
+
COSMOS_SDK_PROTO_URL = file://$(shell go list -m -f '{{ .Dir }}' github.com/cosmos/cosmos-sdk)/proto/cosmos
|
|
106
106
|
|
|
107
107
|
COSMOS_PROTO_TYPES = third_party/proto/cosmos_proto
|
|
108
108
|
GOGO_PROTO_TYPES = third_party/proto/gogoproto
|
|
@@ -116,34 +116,37 @@ SDK_UPGRADE_TYPES = third_party/proto/cosmos/upgrade/v1beta1
|
|
|
116
116
|
|
|
117
117
|
proto-update-deps:
|
|
118
118
|
mkdir -p $(COSMOS_PROTO_TYPES)
|
|
119
|
-
|
|
119
|
+
url="$(COSMOS_PROTO_PROTO_URL)"; \
|
|
120
|
+
curl -sSL $$url/cosmos.proto > $(COSMOS_PROTO_TYPES)/cosmos.proto
|
|
120
121
|
|
|
121
122
|
mkdir -p $(GOGO_PROTO_TYPES)
|
|
122
|
-
|
|
123
|
+
url="$(GOGO_PROTO_URL)"; \
|
|
124
|
+
curl -sSL $$url/gogoproto/gogo.proto > $(GOGO_PROTO_TYPES)/gogo.proto
|
|
123
125
|
|
|
124
126
|
# Downloading from a not-a-go-module is problematic. These files are artifacts for now.
|
|
125
127
|
# mkdir -p $(GOOGLE_API_TYPES)
|
|
126
|
-
#
|
|
127
|
-
# curl -sSL
|
|
128
|
-
# curl -sSL
|
|
128
|
+
# url="$(GOOGLE_API_URL)"; \
|
|
129
|
+
# curl -sSL $$url/annotations.proto > $(GOOGLE_API_TYPES)/annotations.proto && \
|
|
130
|
+
# curl -sSL $$url/http.proto > $(GOOGLE_API_TYPES)/http.proto && \
|
|
131
|
+
# curl -sSL $$url/httpbody.proto > $(GOOGLE_API_TYPES)/httpbody.proto &&
|
|
129
132
|
|
|
130
133
|
mkdir -p $(GOOGLE_PROTO_TYPES)
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
mkdir -p $(SDK_UPGRADE_TYPES)
|
|
146
|
-
curl -sSL
|
|
134
|
+
url="$(GOGO_PROTO_URL)"; \
|
|
135
|
+
curl -sSL $$url/protobuf/google/protobuf/any.proto > $(GOOGLE_PROTO_TYPES)/any.proto
|
|
136
|
+
|
|
137
|
+
url="$(IBC_PROTO_URL)"; \
|
|
138
|
+
mkdir -p $(IBC_CHANNEL_TYPES) && \
|
|
139
|
+
curl -sSL $$url/channel/v1/channel.proto > $(IBC_CHANNEL_TYPES)/channel.proto && \
|
|
140
|
+
mkdir -p $(IBC_CLIENT_TYPES) && \
|
|
141
|
+
curl -sSL $$url/client/v1/client.proto > $(IBC_CLIENT_TYPES)/client.proto
|
|
142
|
+
|
|
143
|
+
url="$(COSMOS_SDK_PROTO_URL)"; \
|
|
144
|
+
mkdir -p $(SDK_BASE_TYPES) && \
|
|
145
|
+
curl -sSL $$url/base/v1beta1/coin.proto > $(SDK_BASE_TYPES)/coin.proto && \
|
|
146
|
+
mkdir -p $(SDK_QUERY_TYPES) && \
|
|
147
|
+
curl -sSL $$url/base/query/v1beta1/pagination.proto > $(SDK_QUERY_TYPES)/pagination.proto && \
|
|
148
|
+
mkdir -p $(SDK_UPGRADE_TYPES) && \
|
|
149
|
+
curl -sSL $$url/upgrade/v1beta1/upgrade.proto > $(SDK_UPGRADE_TYPES)/upgrade.proto
|
|
147
150
|
|
|
148
151
|
UNAME_S ?= $(shell uname -s)
|
|
149
152
|
UNAME_M ?= $(shell uname -m)
|
package/ante/ante.go
CHANGED
|
@@ -45,15 +45,12 @@ func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
|
|
|
45
45
|
anteDecorators := []sdk.AnteDecorator{
|
|
46
46
|
ante.NewSetUpContextDecorator(),
|
|
47
47
|
ante.NewExtensionOptionsDecorator(nil), // reject all extensions
|
|
48
|
-
// former ante.NewMempoolFeeDecorator()
|
|
49
|
-
// replaced as in https://github.com/provenance-io/provenance/pull/1016
|
|
50
|
-
ante.NewDeductFeeDecorator(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, nil),
|
|
51
48
|
ante.NewValidateBasicDecorator(),
|
|
52
49
|
ante.NewTxTimeoutHeightDecorator(),
|
|
53
50
|
ante.NewValidateMemoDecorator(opts.AccountKeeper),
|
|
54
51
|
ante.NewConsumeGasForTxSizeDecorator(opts.AccountKeeper),
|
|
55
52
|
NewInboundDecorator(opts.SwingsetKeeper),
|
|
56
|
-
|
|
53
|
+
ante.NewDeductFeeDecoratorWithName(opts.AccountKeeper, opts.BankKeeper, opts.FeegrantKeeper, nil, opts.FeeCollectorName),
|
|
57
54
|
// SetPubKeyDecorator must be called before all signature verification decorators
|
|
58
55
|
ante.NewSetPubKeyDecorator(opts.AccountKeeper),
|
|
59
56
|
ante.NewValidateSigCountDecorator(opts.AccountKeeper),
|
package/app/app.go
CHANGED
|
@@ -123,9 +123,9 @@ import (
|
|
|
123
123
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage"
|
|
124
124
|
|
|
125
125
|
// Import the packet forward middleware
|
|
126
|
-
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/
|
|
127
|
-
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/
|
|
128
|
-
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/
|
|
126
|
+
packetforward "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward"
|
|
127
|
+
packetforwardkeeper "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/keeper"
|
|
128
|
+
packetforwardtypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v6/packetforward/types"
|
|
129
129
|
|
|
130
130
|
// unnamed import of statik for swagger UI support
|
|
131
131
|
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
|
|
@@ -230,6 +230,9 @@ type GaiaApp struct { // nolint: golint
|
|
|
230
230
|
tkeys map[string]*storetypes.TransientStoreKey
|
|
231
231
|
memKeys map[string]*storetypes.MemoryStoreKey
|
|
232
232
|
|
|
233
|
+
// manage communication from the VM to the ABCI app
|
|
234
|
+
AgdServer *vm.AgdServer
|
|
235
|
+
|
|
233
236
|
// keepers
|
|
234
237
|
AccountKeeper authkeeper.AccountKeeper
|
|
235
238
|
BankKeeper bankkeeper.Keeper
|
|
@@ -298,14 +301,14 @@ func NewGaiaApp(
|
|
|
298
301
|
return "", nil
|
|
299
302
|
}
|
|
300
303
|
return NewAgoricApp(
|
|
301
|
-
defaultController,
|
|
304
|
+
defaultController, vm.NewAgdServer(),
|
|
302
305
|
logger, db, traceStore, loadLatest, skipUpgradeHeights,
|
|
303
306
|
homePath, invCheckPeriod, encodingConfig, appOpts, baseAppOptions...,
|
|
304
307
|
)
|
|
305
308
|
}
|
|
306
309
|
|
|
307
310
|
func NewAgoricApp(
|
|
308
|
-
sendToController func(context.Context, bool, string) (string, error),
|
|
311
|
+
sendToController func(context.Context, bool, string) (string, error), agdServer *vm.AgdServer,
|
|
309
312
|
logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest bool, skipUpgradeHeights map[int64]bool,
|
|
310
313
|
homePath string, invCheckPeriod uint, encodingConfig gaiaappparams.EncodingConfig, appOpts servertypes.AppOptions, baseAppOptions ...func(*baseapp.BaseApp),
|
|
311
314
|
) *GaiaApp {
|
|
@@ -331,6 +334,7 @@ func NewAgoricApp(
|
|
|
331
334
|
|
|
332
335
|
app := &GaiaApp{
|
|
333
336
|
BaseApp: bApp,
|
|
337
|
+
AgdServer: agdServer,
|
|
334
338
|
legacyAmino: legacyAmino,
|
|
335
339
|
appCodec: appCodec,
|
|
336
340
|
interfaceRegistry: interfaceRegistry,
|
|
@@ -449,7 +453,7 @@ func NewAgoricApp(
|
|
|
449
453
|
callToController := func(ctx sdk.Context, str string) (string, error) {
|
|
450
454
|
app.CheckControllerInited(true)
|
|
451
455
|
// We use SwingSet-level metering to charge the user for the call.
|
|
452
|
-
defer
|
|
456
|
+
defer app.AgdServer.SetControllerContext(ctx)()
|
|
453
457
|
return sendToController(sdk.WrapSDKContext(ctx), true, str)
|
|
454
458
|
}
|
|
455
459
|
|
|
@@ -460,7 +464,7 @@ func NewAgoricApp(
|
|
|
460
464
|
app.VstorageKeeper = vstorage.NewKeeper(
|
|
461
465
|
keys[vstorage.StoreKey],
|
|
462
466
|
)
|
|
463
|
-
app.vstoragePort =
|
|
467
|
+
app.vstoragePort = app.AgdServer.MustRegisterPortHandler("vstorage", vstorage.NewStorageHandler(app.VstorageKeeper))
|
|
464
468
|
|
|
465
469
|
// The SwingSetKeeper is the Keeper from the SwingSet module
|
|
466
470
|
app.SwingSetKeeper = swingset.NewKeeper(
|
|
@@ -469,7 +473,7 @@ func NewAgoricApp(
|
|
|
469
473
|
app.VstorageKeeper, vbanktypes.ReservePoolName,
|
|
470
474
|
callToController,
|
|
471
475
|
)
|
|
472
|
-
app.swingsetPort =
|
|
476
|
+
app.swingsetPort = app.AgdServer.MustRegisterPortHandler("swingset", swingset.NewPortHandler(app.SwingSetKeeper))
|
|
473
477
|
|
|
474
478
|
app.SwingStoreExportsHandler = *swingsetkeeper.NewSwingStoreExportsHandler(
|
|
475
479
|
app.Logger(),
|
|
@@ -508,7 +512,7 @@ func NewAgoricApp(
|
|
|
508
512
|
|
|
509
513
|
vibcModule := vibc.NewAppModule(app.VibcKeeper, app.BankKeeper)
|
|
510
514
|
vibcIBCModule := vibc.NewIBCModule(app.VibcKeeper)
|
|
511
|
-
app.vibcPort =
|
|
515
|
+
app.vibcPort = app.AgdServer.MustRegisterPortHandler("vibc", vibc.NewReceiver(app.VibcKeeper))
|
|
512
516
|
|
|
513
517
|
app.VbankKeeper = vbank.NewKeeper(
|
|
514
518
|
appCodec, keys[vbank.StoreKey], app.GetSubspace(vbank.ModuleName),
|
|
@@ -516,7 +520,7 @@ func NewAgoricApp(
|
|
|
516
520
|
app.SwingSetKeeper.PushAction,
|
|
517
521
|
)
|
|
518
522
|
vbankModule := vbank.NewAppModule(app.VbankKeeper)
|
|
519
|
-
app.vbankPort =
|
|
523
|
+
app.vbankPort = app.AgdServer.MustRegisterPortHandler("bank", vbank.NewPortHandler(vbankModule, app.VbankKeeper))
|
|
520
524
|
|
|
521
525
|
// register the proposal types
|
|
522
526
|
govRouter := govv1beta1.NewRouter()
|
|
@@ -613,7 +617,7 @@ func NewAgoricApp(
|
|
|
613
617
|
app.BaseApp.MsgServiceRouter(),
|
|
614
618
|
app.BaseApp.GRPCQueryRouter(),
|
|
615
619
|
)
|
|
616
|
-
app.vlocalchainPort =
|
|
620
|
+
app.vlocalchainPort = app.AgdServer.MustRegisterPortHandler(
|
|
617
621
|
"vlocalchain",
|
|
618
622
|
vlocalchain.NewReceiver(app.VlocalchainKeeper),
|
|
619
623
|
)
|
|
@@ -817,25 +821,18 @@ func NewAgoricApp(
|
|
|
817
821
|
app.SetBeginBlocker(app.BeginBlocker)
|
|
818
822
|
app.SetEndBlocker(app.EndBlocker)
|
|
819
823
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
upgradeName,
|
|
827
|
-
unreleasedUpgradeHandler(app, upgradeName),
|
|
828
|
-
)
|
|
829
|
-
app.UpgradeKeeper.SetUpgradeHandler(
|
|
830
|
-
upgradeNameTest,
|
|
831
|
-
unreleasedUpgradeHandler(app, upgradeNameTest),
|
|
832
|
-
)
|
|
824
|
+
for name := range upgradeNamesOfThisVersion {
|
|
825
|
+
app.UpgradeKeeper.SetUpgradeHandler(
|
|
826
|
+
name,
|
|
827
|
+
unreleasedUpgradeHandler(app, name),
|
|
828
|
+
)
|
|
829
|
+
}
|
|
833
830
|
|
|
834
831
|
upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
|
|
835
832
|
if err != nil {
|
|
836
833
|
panic(err)
|
|
837
834
|
}
|
|
838
|
-
if
|
|
835
|
+
if upgradeNamesOfThisVersion[upgradeInfo.Name] && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
|
|
839
836
|
storeUpgrades := storetypes.StoreUpgrades{
|
|
840
837
|
Added: []string{
|
|
841
838
|
packetforwardtypes.ModuleName, // Added PFM
|
|
@@ -871,25 +868,58 @@ func NewAgoricApp(
|
|
|
871
868
|
return app
|
|
872
869
|
}
|
|
873
870
|
|
|
871
|
+
var upgradeNamesOfThisVersion = map[string]bool{
|
|
872
|
+
"UNRELEASED_UPGRADE": true,
|
|
873
|
+
"UNRELEASED_TEST_UPGRADE": true,
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
func isFirstTimeUpgradeOfThisVersion(app *GaiaApp, ctx sdk.Context) bool {
|
|
877
|
+
for name := range upgradeNamesOfThisVersion {
|
|
878
|
+
if app.UpgradeKeeper.GetDoneHeight(ctx, name) != 0 {
|
|
879
|
+
return false
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return true
|
|
883
|
+
}
|
|
884
|
+
|
|
874
885
|
// unreleasedUpgradeHandler performs standard upgrade actions plus custom actions for the unreleased upgrade.
|
|
875
886
|
func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
876
887
|
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
877
888
|
app.CheckControllerInited(false)
|
|
878
889
|
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
CoreProposalSteps
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
//
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
"@agoric/builders/scripts/vats/
|
|
892
|
-
|
|
890
|
+
CoreProposalSteps := []vm.CoreProposalStep{}
|
|
891
|
+
|
|
892
|
+
// These CoreProposalSteps are not idempotent and should only be executed
|
|
893
|
+
// as part of the first upgrade using this handler on any given chain.
|
|
894
|
+
if isFirstTimeUpgradeOfThisVersion(app, ctx) {
|
|
895
|
+
// Each CoreProposalStep runs sequentially, and can be constructed from
|
|
896
|
+
// one or more modules executing in parallel within the step.
|
|
897
|
+
CoreProposalSteps = []vm.CoreProposalStep{
|
|
898
|
+
// Upgrade ZCF only
|
|
899
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgrade-zcf.js"),
|
|
900
|
+
|
|
901
|
+
// upgrade the provisioning vat
|
|
902
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-provisioning.js"),
|
|
903
|
+
// Enable low-level Orchestration.
|
|
904
|
+
vm.CoreProposalStepForModules(
|
|
905
|
+
"@agoric/builders/scripts/vats/init-network.js",
|
|
906
|
+
"@agoric/builders/scripts/vats/init-localchain.js",
|
|
907
|
+
),
|
|
908
|
+
// Add new vats for price feeds. The existing ones will be retired shortly.
|
|
909
|
+
vm.CoreProposalStepForModules(
|
|
910
|
+
"@agoric/builders/scripts/vats/updateAtomPriceFeed.js",
|
|
911
|
+
"@agoric/builders/scripts/vats/updateStAtomPriceFeed.js",
|
|
912
|
+
"@agoric/builders/scripts/vats/updateStOsmoPriceFeed.js",
|
|
913
|
+
"@agoric/builders/scripts/vats/updateStTiaPriceFeed.js",
|
|
914
|
+
"@agoric/builders/scripts/vats/updateStkAtomPriceFeed.js",
|
|
915
|
+
),
|
|
916
|
+
// Add new auction contract. The old one will be retired shortly.
|
|
917
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/add-auction.js"),
|
|
918
|
+
// upgrade vaultFactory.
|
|
919
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgradeVaults.js"),
|
|
920
|
+
// upgrade scaledPriceAuthorities.
|
|
921
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgradeScaledPriceAuthorities.js"),
|
|
922
|
+
}
|
|
893
923
|
}
|
|
894
924
|
|
|
895
925
|
app.upgradeDetails = &upgradeDetails{
|
package/cmd/agd/main.go
CHANGED
|
@@ -49,7 +49,6 @@ func makeShutdown(cmd *exec.Cmd, writer *os.File) func() error {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
52
|
// main is the entry point of the agd daemon. It determines whether to
|
|
54
53
|
// initialize JSON-RPC communications with the separate `--split-vm` VM process,
|
|
55
54
|
// or just to give up control entirely to another binary.
|
|
@@ -72,9 +71,9 @@ func main() {
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
msg := vm.Message{
|
|
75
|
-
Port:
|
|
74
|
+
Port: nodePort,
|
|
76
75
|
NeedsReply: needReply,
|
|
77
|
-
Data:
|
|
76
|
+
Data: str,
|
|
78
77
|
}
|
|
79
78
|
var reply string
|
|
80
79
|
err := vmClient.Call(vm.ReceiveMessageMethod, msg, &reply)
|
|
@@ -82,7 +81,7 @@ func main() {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
exitCode := 0
|
|
85
|
-
launchVM := func(logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
84
|
+
launchVM := func(agdServer *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
86
85
|
args := []string{"ag-chain-cosmos", "--home", gaia.DefaultNodeHome}
|
|
87
86
|
args = append(args, os.Args[1:]...)
|
|
88
87
|
|
|
@@ -129,7 +128,7 @@ func main() {
|
|
|
129
128
|
|
|
130
129
|
// Set up the VM server.
|
|
131
130
|
vmServer := rpc.NewServer()
|
|
132
|
-
if err := vmServer.RegisterName("agd",
|
|
131
|
+
if err := vmServer.RegisterName("agd", agdServer); err != nil {
|
|
133
132
|
return err
|
|
134
133
|
}
|
|
135
134
|
go vmServer.ServeCodec(jsonrpc.NewServerCodec(serverConn))
|
|
@@ -147,11 +146,11 @@ func main() {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
daemoncmd.OnExportHook = launchVM
|
|
150
|
-
daemoncmd.OnStartHook = func
|
|
149
|
+
daemoncmd.OnStartHook = func(agdServer *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
151
150
|
// We tried running start, which should never exit, so exit with non-zero
|
|
152
151
|
// code if we do.
|
|
153
152
|
exitCode = 99
|
|
154
|
-
return launchVM(logger, appOpts)
|
|
153
|
+
return launchVM(agdServer, logger, appOpts)
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
daemon.RunWithController(sendToNode)
|
package/cmd/libdaemon/main.go
CHANGED
|
@@ -38,7 +38,7 @@ var agdServer *vm.AgdServer
|
|
|
38
38
|
// ConnectVMClientCodec creates an RPC client codec and a sender to the
|
|
39
39
|
// in-process implementation of the VM.
|
|
40
40
|
func ConnectVMClientCodec(ctx context.Context, nodePort int, sendFunc func(int, int, string)) (*vm.ClientCodec, daemoncmd.Sender) {
|
|
41
|
-
vmClientCodec = vm.NewClientCodec(
|
|
41
|
+
vmClientCodec = vm.NewClientCodec(ctx, sendFunc)
|
|
42
42
|
vmClient := rpc.NewClientWithCodec(vmClientCodec)
|
|
43
43
|
|
|
44
44
|
sendToNode := func(ctx context.Context, needReply bool, str string) (string, error) {
|
|
@@ -47,9 +47,9 @@ func ConnectVMClientCodec(ctx context.Context, nodePort int, sendFunc func(int,
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
msg := vm.Message{
|
|
50
|
-
Port:
|
|
50
|
+
Port: nodePort,
|
|
51
51
|
NeedsReply: needReply,
|
|
52
|
-
Data:
|
|
52
|
+
Data: str,
|
|
53
53
|
}
|
|
54
54
|
var reply string
|
|
55
55
|
err := vmClient.Call(vm.ReceiveMessageMethod, msg, &reply)
|
|
@@ -83,7 +83,6 @@ func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char)
|
|
|
83
83
|
int(nodePort),
|
|
84
84
|
sendFunc,
|
|
85
85
|
)
|
|
86
|
-
agdServer = vm.NewAgdServer()
|
|
87
86
|
|
|
88
87
|
args := make([]string, len(cosmosArgs))
|
|
89
88
|
for i, s := range cosmosArgs {
|
|
@@ -96,7 +95,8 @@ func RunAgCosmosDaemon(nodePort C.int, toNode C.sendFunc, cosmosArgs []*C.char)
|
|
|
96
95
|
// We run in the background, but exit when the job is over.
|
|
97
96
|
// swingset.SendToNode("hello from Initial Go!")
|
|
98
97
|
exitCode := 0
|
|
99
|
-
daemoncmd.OnStartHook = func(logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
98
|
+
daemoncmd.OnStartHook = func(srv *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
99
|
+
agdServer = srv
|
|
100
100
|
// We tried running start, which should never exit, so exit with non-zero
|
|
101
101
|
// code if we ever stop.
|
|
102
102
|
exitCode = 99
|
|
@@ -130,11 +130,11 @@ func SendToGo(port C.int, msg C.Body) C.Body {
|
|
|
130
130
|
// fmt.Fprintln(os.Stderr, "Send to Go", msgStr)
|
|
131
131
|
var respStr string
|
|
132
132
|
message := &vm.Message{
|
|
133
|
-
Port:
|
|
133
|
+
Port: int(port),
|
|
134
134
|
NeedsReply: true,
|
|
135
|
-
Data:
|
|
135
|
+
Data: msgStr,
|
|
136
136
|
}
|
|
137
|
-
|
|
137
|
+
|
|
138
138
|
err := agdServer.ReceiveMessage(message, &respStr)
|
|
139
139
|
if err == nil {
|
|
140
140
|
return C.CString(respStr)
|
package/daemon/cmd/root.go
CHANGED
|
@@ -39,14 +39,15 @@ import (
|
|
|
39
39
|
|
|
40
40
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
41
41
|
"github.com/Agoric/agoric-sdk/golang/cosmos/app/params"
|
|
42
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
42
43
|
)
|
|
43
44
|
|
|
44
45
|
// Sender is a function that sends a request to the controller.
|
|
45
46
|
type Sender func(ctx context.Context, needReply bool, str string) (string, error)
|
|
46
47
|
|
|
47
48
|
var AppName = "agd"
|
|
48
|
-
var OnStartHook func(log.Logger, servertypes.AppOptions) error
|
|
49
|
-
var OnExportHook func(log.Logger, servertypes.AppOptions) error
|
|
49
|
+
var OnStartHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
50
|
+
var OnExportHook func(*vm.AgdServer, log.Logger, servertypes.AppOptions) error
|
|
50
51
|
|
|
51
52
|
// NewRootCmd creates a new root command for simd. It is called once in the
|
|
52
53
|
// main function.
|
|
@@ -129,8 +130,9 @@ func initRootCmd(sender Sender, rootCmd *cobra.Command, encodingConfig params.En
|
|
|
129
130
|
cfg.Seal()
|
|
130
131
|
|
|
131
132
|
ac := appCreator{
|
|
132
|
-
encCfg:
|
|
133
|
-
sender:
|
|
133
|
+
encCfg: encodingConfig,
|
|
134
|
+
sender: sender,
|
|
135
|
+
agdServer: vm.NewAgdServer(),
|
|
134
136
|
}
|
|
135
137
|
|
|
136
138
|
rootCmd.AddCommand(
|
|
@@ -249,8 +251,9 @@ func txCommand() *cobra.Command {
|
|
|
249
251
|
}
|
|
250
252
|
|
|
251
253
|
type appCreator struct {
|
|
252
|
-
encCfg
|
|
253
|
-
sender
|
|
254
|
+
encCfg params.EncodingConfig
|
|
255
|
+
sender Sender
|
|
256
|
+
agdServer *vm.AgdServer
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
func (ac appCreator) newApp(
|
|
@@ -260,7 +263,7 @@ func (ac appCreator) newApp(
|
|
|
260
263
|
appOpts servertypes.AppOptions,
|
|
261
264
|
) servertypes.Application {
|
|
262
265
|
if OnStartHook != nil {
|
|
263
|
-
if err := OnStartHook(logger, appOpts); err != nil {
|
|
266
|
+
if err := OnStartHook(ac.agdServer, logger, appOpts); err != nil {
|
|
264
267
|
panic(err)
|
|
265
268
|
}
|
|
266
269
|
}
|
|
@@ -305,7 +308,7 @@ func (ac appCreator) newApp(
|
|
|
305
308
|
)
|
|
306
309
|
|
|
307
310
|
return gaia.NewAgoricApp(
|
|
308
|
-
ac.sender,
|
|
311
|
+
ac.sender, ac.agdServer,
|
|
309
312
|
logger, db, traceStore, true, skipUpgradeHeights,
|
|
310
313
|
homePath,
|
|
311
314
|
cast.ToUint(appOpts.Get(server.FlagInvCheckPeriod)),
|
|
@@ -320,6 +323,9 @@ func (ac appCreator) newApp(
|
|
|
320
323
|
baseapp.SetTrace(cast.ToBool(appOpts.Get(server.FlagTrace))),
|
|
321
324
|
baseapp.SetIndexEvents(cast.ToStringSlice(appOpts.Get(server.FlagIndexEvents))),
|
|
322
325
|
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
|
|
326
|
+
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(server.FlagIAVLCacheSize))),
|
|
327
|
+
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(server.FlagDisableIAVLFastNode))),
|
|
328
|
+
baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(server.FlagIAVLLazyLoading))),
|
|
323
329
|
)
|
|
324
330
|
}
|
|
325
331
|
|
|
@@ -405,7 +411,7 @@ func (ac appCreator) appExport(
|
|
|
405
411
|
appOpts servertypes.AppOptions,
|
|
406
412
|
) (servertypes.ExportedApp, error) {
|
|
407
413
|
if OnExportHook != nil {
|
|
408
|
-
if err := OnExportHook(logger, appOpts); err != nil {
|
|
414
|
+
if err := OnExportHook(ac.agdServer, logger, appOpts); err != nil {
|
|
409
415
|
return servertypes.ExportedApp{}, err
|
|
410
416
|
}
|
|
411
417
|
}
|
|
@@ -421,7 +427,7 @@ func (ac appCreator) appExport(
|
|
|
421
427
|
}
|
|
422
428
|
|
|
423
429
|
gaiaApp := gaia.NewAgoricApp(
|
|
424
|
-
ac.sender,
|
|
430
|
+
ac.sender, ac.agdServer,
|
|
425
431
|
logger,
|
|
426
432
|
db,
|
|
427
433
|
traceStore,
|