@agoric/cosmos 0.34.1 → 0.34.2-calypso-dev-dabccdc.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/export.go
CHANGED
|
@@ -44,9 +44,10 @@ func (app *GaiaApp) ExportAppStateAndValidators(
|
|
|
44
44
|
}, err
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
//
|
|
47
|
+
// prepForZeroHeightGenesis prepares for a fresh start at zero height.
|
|
48
|
+
//
|
|
49
|
+
// NOTE: Zero height genesis is a temporary feature which will be deprecated
|
|
50
|
+
// in favour of export at a block height.
|
|
50
51
|
func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
|
|
51
52
|
applyAllowedAddrs := false
|
|
52
53
|
|
|
@@ -65,9 +66,6 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
|
|
|
65
66
|
allowedAddrsMap[addr] = true
|
|
66
67
|
}
|
|
67
68
|
|
|
68
|
-
/* Just to be safe, assert the invariants on current state. */
|
|
69
|
-
app.CrisisKeeper.AssertInvariants(ctx)
|
|
70
|
-
|
|
71
69
|
/* Handle fee distribution state. */
|
|
72
70
|
|
|
73
71
|
// withdraw all validator commission
|
|
@@ -109,7 +107,9 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
|
|
|
109
107
|
feePool.CommunityPool = feePool.CommunityPool.Add(scraps...)
|
|
110
108
|
app.DistrKeeper.SetFeePool(ctx, feePool)
|
|
111
109
|
|
|
112
|
-
app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator())
|
|
110
|
+
if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil {
|
|
111
|
+
panic(err)
|
|
112
|
+
}
|
|
113
113
|
return false
|
|
114
114
|
})
|
|
115
115
|
|
|
@@ -123,8 +123,12 @@ func (app *GaiaApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [
|
|
|
123
123
|
if err != nil {
|
|
124
124
|
panic(err)
|
|
125
125
|
}
|
|
126
|
-
app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr)
|
|
127
|
-
|
|
126
|
+
if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil {
|
|
127
|
+
panic(err)
|
|
128
|
+
}
|
|
129
|
+
if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil {
|
|
130
|
+
panic(err)
|
|
131
|
+
}
|
|
128
132
|
}
|
|
129
133
|
|
|
130
134
|
// reset context height
|
package/app/sim_test.go
CHANGED
|
@@ -6,9 +6,9 @@ import (
|
|
|
6
6
|
"os"
|
|
7
7
|
"testing"
|
|
8
8
|
|
|
9
|
-
gaia "github.com/
|
|
9
|
+
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
10
10
|
|
|
11
|
-
"github.com/
|
|
11
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/app/helpers"
|
|
12
12
|
"github.com/stretchr/testify/require"
|
|
13
13
|
"github.com/tendermint/tendermint/libs/log"
|
|
14
14
|
"github.com/tendermint/tendermint/libs/rand"
|
|
@@ -76,8 +76,8 @@ func interBlockCacheOpt() func(*baseapp.BaseApp) {
|
|
|
76
76
|
return baseapp.SetInterBlockCache(store.NewCommitKVStoreCacheManager())
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
// // TODO: Make another test for the fuzzer itself, which just has noOp txs
|
|
80
|
+
// // and doesn't depend on the application.
|
|
81
81
|
func TestAppStateDeterminism(t *testing.T) {
|
|
82
82
|
if !simapp.FlagEnabledValue {
|
|
83
83
|
t.Skip("skipping application simulation")
|
package/app/upgrade.go
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
package gaia
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"encoding/json"
|
|
5
|
+
"fmt"
|
|
6
|
+
"strings"
|
|
7
|
+
"text/template"
|
|
8
|
+
|
|
9
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
10
|
+
swingsetkeeper "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
|
|
11
|
+
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
12
|
+
"github.com/cosmos/cosmos-sdk/types/module"
|
|
13
|
+
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
var upgradeNamesOfThisVersion = map[string]bool{
|
|
17
|
+
"UNRELEASED_BASIC": true, // no-frills
|
|
18
|
+
"UNRELEASED_A3P_INTEGRATION": true,
|
|
19
|
+
"UNRELEASED_main": true,
|
|
20
|
+
"UNRELEASED_devnet": true,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
func isFirstTimeUpgradeOfThisVersion(app *GaiaApp, ctx sdk.Context) bool {
|
|
24
|
+
for name := range upgradeNamesOfThisVersion {
|
|
25
|
+
if app.UpgradeKeeper.GetDoneHeight(ctx, name) != 0 {
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return true
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// upgradePriceFeedCoreProposalSteps returns the core proposal steps for the
|
|
33
|
+
// price feed upgrade and associated changes to scaledPriceAuthority and
|
|
34
|
+
// vaultManager.
|
|
35
|
+
func upgradePriceFeedCoreProposalSteps(upgradeName string) ([]vm.CoreProposalStep, error) {
|
|
36
|
+
isThisUpgrade := func(expectedUpgradeName string) bool {
|
|
37
|
+
if !upgradeNamesOfThisVersion[expectedUpgradeName] {
|
|
38
|
+
panic(fmt.Errorf("invalid upgrade name: %s", expectedUpgradeName))
|
|
39
|
+
}
|
|
40
|
+
return upgradeName == expectedUpgradeName
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
t := template.Must(template.New("").Parse(`{
|
|
44
|
+
"module": "@agoric/builders/scripts/vats/priceFeedSupport.js",
|
|
45
|
+
"entrypoint": {{.entrypointJson}},
|
|
46
|
+
"args": [{
|
|
47
|
+
"AGORIC_INSTANCE_NAME": {{.instanceNameJson}},
|
|
48
|
+
"ORACLE_ADDRESSES": {{.oracleAddressesJson}},
|
|
49
|
+
"IN_BRAND_LOOKUP": {{.inBrandLookupJson}},
|
|
50
|
+
"IN_BRAND_DECIMALS": 6,
|
|
51
|
+
"OUT_BRAND_LOOKUP": ["agoricNames", "oracleBrand", "USD"],
|
|
52
|
+
"OUT_BRAND_DECIMALS": 4
|
|
53
|
+
}]
|
|
54
|
+
}`))
|
|
55
|
+
|
|
56
|
+
var oracleAddresses []string
|
|
57
|
+
|
|
58
|
+
var entrypoint string
|
|
59
|
+
switch {
|
|
60
|
+
case isThisUpgrade("UNRELEASED_A3P_INTEGRATION"):
|
|
61
|
+
entrypoint = "deprecatedPriceFeedProposalBuilder"
|
|
62
|
+
case isThisUpgrade("UNRELEASED_main"):
|
|
63
|
+
oracleAddresses = []string{
|
|
64
|
+
"agoric144rrhh4m09mh7aaffhm6xy223ym76gve2x7y78", // DSRV
|
|
65
|
+
"agoric19d6gnr9fyp6hev4tlrg87zjrzsd5gzr5qlfq2p", // Stakin
|
|
66
|
+
"agoric19uscwxdac6cf6z7d5e26e0jm0lgwstc47cpll8", // 01node
|
|
67
|
+
"agoric1krunjcqfrf7la48zrvdfeeqtls5r00ep68mzkr", // Simply Staking
|
|
68
|
+
"agoric1n4fcxsnkxe4gj6e24naec99hzmc4pjfdccy5nj", // P2P
|
|
69
|
+
}
|
|
70
|
+
entrypoint = "strictPriceFeedProposalBuilder"
|
|
71
|
+
case isThisUpgrade("UNRELEASED_devnet"):
|
|
72
|
+
oracleAddresses = []string{
|
|
73
|
+
"agoric1lw4e4aas9q84tq0q92j85rwjjjapf8dmnllnft", // DSRV
|
|
74
|
+
"agoric1zj6vrrrjq4gsyr9lw7dplv4vyejg3p8j2urm82", // Stakin
|
|
75
|
+
"agoric1ra0g6crtsy6r3qnpu7ruvm7qd4wjnznyzg5nu4", // 01node
|
|
76
|
+
"agoric1qj07c7vfk3knqdral0sej7fa6eavkdn8vd8etf", // Simply Staking
|
|
77
|
+
"agoric10vjkvkmpp9e356xeh6qqlhrny2htyzp8hf88fk", // P2P
|
|
78
|
+
}
|
|
79
|
+
entrypoint = "strictPriceFeedProposalBuilder"
|
|
80
|
+
|
|
81
|
+
// No price feed upgrade for this version.
|
|
82
|
+
case isThisUpgrade("UNRELEASED_BASIC"):
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if entrypoint == "" {
|
|
86
|
+
return []vm.CoreProposalStep{}, nil
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
entrypointJson, err := json.Marshal(entrypoint)
|
|
90
|
+
if err != nil {
|
|
91
|
+
return nil, err
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
var inBrandNames []string
|
|
95
|
+
switch {
|
|
96
|
+
case isThisUpgrade("UNRELEASED_A3P_INTEGRATION"), isThisUpgrade("UNRELEASED_main"):
|
|
97
|
+
inBrandNames = []string{
|
|
98
|
+
"ATOM",
|
|
99
|
+
"stATOM",
|
|
100
|
+
"stOSMO",
|
|
101
|
+
"stTIA",
|
|
102
|
+
"stkATOM",
|
|
103
|
+
}
|
|
104
|
+
case isThisUpgrade("UNRELEASED_devnet"):
|
|
105
|
+
inBrandNames = []string{
|
|
106
|
+
"ATOM",
|
|
107
|
+
"stTIA",
|
|
108
|
+
"stkATOM",
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
oracleAddressesJson, err := json.Marshal(oracleAddresses)
|
|
113
|
+
if err != nil {
|
|
114
|
+
return nil, err
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
proposals := make(vm.CoreProposalStep, 0, len(inBrandNames))
|
|
118
|
+
for _, inBrandName := range inBrandNames {
|
|
119
|
+
instanceName := inBrandName + "-USD price feed"
|
|
120
|
+
instanceNameJson, err := json.Marshal(instanceName)
|
|
121
|
+
if err != nil {
|
|
122
|
+
return nil, err
|
|
123
|
+
}
|
|
124
|
+
inBrandLookup := []string{"agoricNames", "oracleBrand", inBrandName}
|
|
125
|
+
inBrandLookupJson, err := json.Marshal(inBrandLookup)
|
|
126
|
+
if err != nil {
|
|
127
|
+
return nil, err
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
var result strings.Builder
|
|
131
|
+
err = t.Execute(&result, map[string]any{
|
|
132
|
+
"entrypointJson": string(entrypointJson),
|
|
133
|
+
"inBrandLookupJson": string(inBrandLookupJson),
|
|
134
|
+
"instanceNameJson": string(instanceNameJson),
|
|
135
|
+
"oracleAddressesJson": string(oracleAddressesJson),
|
|
136
|
+
})
|
|
137
|
+
if err != nil {
|
|
138
|
+
return nil, err
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
jsonStr := result.String()
|
|
142
|
+
jsonBz := []byte(jsonStr)
|
|
143
|
+
if !json.Valid(jsonBz) {
|
|
144
|
+
return nil, fmt.Errorf("invalid JSON: %s", jsonStr)
|
|
145
|
+
}
|
|
146
|
+
proposals = append(proposals, vm.ArbitraryCoreProposal{Json: jsonBz})
|
|
147
|
+
}
|
|
148
|
+
return []vm.CoreProposalStep{
|
|
149
|
+
// Add new vats for price feeds. The existing ones will be retired shortly.
|
|
150
|
+
vm.CoreProposalStepForModules(proposals...),
|
|
151
|
+
// Add new auction contract. The old one will be retired shortly.
|
|
152
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/add-auction.js"),
|
|
153
|
+
// upgrade vaultFactory.
|
|
154
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/upgradeVaults.js"),
|
|
155
|
+
}, nil
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// unreleasedUpgradeHandler performs standard upgrade actions plus custom actions for the unreleased upgrade.
|
|
159
|
+
func unreleasedUpgradeHandler(app *GaiaApp, targetUpgrade string) func(sdk.Context, upgradetypes.Plan, module.VersionMap) (module.VersionMap, error) {
|
|
160
|
+
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVm module.VersionMap) (module.VersionMap, error) {
|
|
161
|
+
app.CheckControllerInited(false)
|
|
162
|
+
|
|
163
|
+
CoreProposalSteps := []vm.CoreProposalStep{}
|
|
164
|
+
|
|
165
|
+
// These CoreProposalSteps are not idempotent and should only be executed
|
|
166
|
+
// as part of the first upgrade using this handler on any given chain.
|
|
167
|
+
if isFirstTimeUpgradeOfThisVersion(app, ctx) {
|
|
168
|
+
// Each CoreProposalStep runs sequentially, and can be constructed from
|
|
169
|
+
// one or more modules executing in parallel within the step.
|
|
170
|
+
CoreProposalSteps = []vm.CoreProposalStep{
|
|
171
|
+
// Upgrade Zoe + ZCF
|
|
172
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-zoe.js"),
|
|
173
|
+
// Revive KREAd characters
|
|
174
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/revive-kread.js"),
|
|
175
|
+
|
|
176
|
+
// upgrade the provisioning vat
|
|
177
|
+
vm.CoreProposalStepForModules("@agoric/builders/scripts/vats/replace-provisioning.js"),
|
|
178
|
+
// Enable low-level Orchestration.
|
|
179
|
+
vm.CoreProposalStepForModules(
|
|
180
|
+
"@agoric/builders/scripts/vats/init-network.js",
|
|
181
|
+
"@agoric/builders/scripts/vats/init-localchain.js",
|
|
182
|
+
"@agoric/builders/scripts/vats/init-transfer.js",
|
|
183
|
+
),
|
|
184
|
+
}
|
|
185
|
+
priceFeedSteps, err := upgradePriceFeedCoreProposalSteps(targetUpgrade)
|
|
186
|
+
if err != nil {
|
|
187
|
+
return nil, err
|
|
188
|
+
}
|
|
189
|
+
CoreProposalSteps = append(CoreProposalSteps, priceFeedSteps...)
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
app.upgradeDetails = &upgradeDetails{
|
|
193
|
+
// Record the plan to send to SwingSet
|
|
194
|
+
Plan: plan,
|
|
195
|
+
// Core proposals that should run during the upgrade block
|
|
196
|
+
// These will be merged with any coreProposals specified in the
|
|
197
|
+
// upgradeInfo field of the upgrade plan ran as subsequent steps
|
|
198
|
+
CoreProposals: vm.CoreProposalsFromSteps(CoreProposalSteps...),
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Always run module migrations
|
|
202
|
+
mvm, err := app.mm.RunMigrations(ctx, app.configurator, fromVm)
|
|
203
|
+
if err != nil {
|
|
204
|
+
return mvm, err
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
m := swingsetkeeper.NewMigrator(app.SwingSetKeeper)
|
|
208
|
+
err = m.MigrateParams(ctx)
|
|
209
|
+
if err != nil {
|
|
210
|
+
return mvm, err
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
return mvm, nil
|
|
214
|
+
}
|
|
215
|
+
}
|
package/binding.gyp.in
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
"targets": [
|
|
3
3
|
{
|
|
4
4
|
"target_name": "agcosmosdaemon",
|
|
5
|
+
'variables': {
|
|
6
|
+
"target_lib": "lib<(_target_name).so",
|
|
7
|
+
},
|
|
5
8
|
"cflags!": [ "-fno-exceptions" ],
|
|
6
9
|
"cflags_cc!": [ "-fno-exceptions" ],
|
|
7
10
|
"xcode_settings": {
|
|
@@ -18,17 +21,39 @@
|
|
|
18
21
|
"<!@(node -p \"require('napi-thread-safe-callback').include\")"
|
|
19
22
|
],
|
|
20
23
|
"dependencies": ["<!(node -p \"require('node-addon-api').gyp\")"],
|
|
21
|
-
"libraries": [
|
|
24
|
+
"libraries": [
|
|
25
|
+
"<(target_lib)"
|
|
26
|
+
],
|
|
22
27
|
"conditions": [
|
|
23
28
|
['OS=="mac"', {
|
|
24
29
|
'cflags+': ['-fvisibility=hidden'],
|
|
25
30
|
'xcode_settings': {
|
|
26
31
|
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
|
|
27
|
-
}
|
|
32
|
+
},
|
|
33
|
+
'libraries+': [
|
|
34
|
+
"-Wl,-rpath,@loader_path/..",
|
|
35
|
+
],
|
|
36
|
+
'postbuilds': [
|
|
37
|
+
{
|
|
38
|
+
'postbuild_name': 'Adding @rpath prefix to <(target_lib)',
|
|
39
|
+
'action': [
|
|
40
|
+
'install_name_tool',
|
|
41
|
+
'-change',
|
|
42
|
+
'<(target_lib)',
|
|
43
|
+
'@rpath/<(target_lib)',
|
|
44
|
+
'<(PRODUCT_DIR)/<(_target_name).node',
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
],
|
|
28
48
|
}],
|
|
29
49
|
['OS=="win"', {
|
|
30
|
-
'defines': [ '_HAS_EXCEPTIONS=1' ]
|
|
31
|
-
}]
|
|
50
|
+
'defines': [ '_HAS_EXCEPTIONS=1' ],
|
|
51
|
+
}],
|
|
52
|
+
['OS=="linux"', {
|
|
53
|
+
'libraries+': [
|
|
54
|
+
"-Wl,-rpath,'$$ORIGIN/..'",
|
|
55
|
+
],
|
|
56
|
+
}],
|
|
32
57
|
]
|
|
33
58
|
},
|
|
34
59
|
],
|
package/buf.work.yaml
ADDED
package/cmd/agd/agvm.go
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"fmt"
|
|
5
|
+
"os"
|
|
6
|
+
"os/exec"
|
|
7
|
+
|
|
8
|
+
"github.com/tendermint/tendermint/libs/log"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// NewVMCommand creates a new OS command to run the Agoric VM. It sets up the
|
|
12
|
+
// file descriptors for the VM to communicate with agd, and passes their numbers
|
|
13
|
+
// via AGVM_FROM_AGD and AGVM_TO_AGD environment variables.
|
|
14
|
+
func NewVMCommand(logger log.Logger, binary string, args []string, vmFromAgd, vmToAgd *os.File) *exec.Cmd {
|
|
15
|
+
logger.Info("agd connecting to VM", "binary", binary, "args", args)
|
|
16
|
+
cmd := exec.Command(binary, args[1:]...)
|
|
17
|
+
|
|
18
|
+
// Manage the file descriptors.
|
|
19
|
+
cmd.Stdout = os.Stdout
|
|
20
|
+
cmd.Stderr = os.Stderr
|
|
21
|
+
cmd.Stdin = os.Stdin
|
|
22
|
+
numStdFiles := 3 // stdin, stdout, stderr
|
|
23
|
+
|
|
24
|
+
// We start our file descriptor allocations after the standard ones, including
|
|
25
|
+
// Node.js IPC (fd=3).
|
|
26
|
+
fdFromAgd := 4
|
|
27
|
+
fdToAgd := fdFromAgd + 1
|
|
28
|
+
|
|
29
|
+
// ExtraFiles begins at fd numStdFiles, so we need to compute the array.
|
|
30
|
+
cmd.ExtraFiles = make([]*os.File, fdToAgd - numStdFiles + 1)
|
|
31
|
+
cmd.ExtraFiles[fdFromAgd - numStdFiles] = vmFromAgd
|
|
32
|
+
cmd.ExtraFiles[fdToAgd - numStdFiles] = vmToAgd
|
|
33
|
+
|
|
34
|
+
// Pass the file descriptor numbers in the environment.
|
|
35
|
+
cmd.Env = append(
|
|
36
|
+
os.Environ(),
|
|
37
|
+
fmt.Sprintf("AGVM_FROM_AGD=%d", fdFromAgd),
|
|
38
|
+
fmt.Sprintf("AGVM_TO_AGD=%d", fdToAgd),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
return cmd
|
|
42
|
+
}
|
package/cmd/agd/find_binary.go
CHANGED
|
@@ -8,14 +8,19 @@ import (
|
|
|
8
8
|
|
|
9
9
|
// FindBinaryNextToMe looks for binName next to the current executable.
|
|
10
10
|
// It returns an absolute filename for binName, or an error.
|
|
11
|
-
func FindBinaryNextToMe(
|
|
11
|
+
func FindBinaryNextToMe(walkUp int, path... string) (string, error) {
|
|
12
12
|
ex, err := os.Executable()
|
|
13
13
|
if err != nil {
|
|
14
14
|
return "", err
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
// Calculate the binary's filename.
|
|
18
|
-
|
|
18
|
+
dir := ex
|
|
19
|
+
for i := 0; i <= walkUp; i++ {
|
|
20
|
+
dir = filepath.Dir(dir)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
bin := filepath.Join(append([]string{dir}, path...)...)
|
|
19
24
|
|
|
20
25
|
// Take the absolute path.
|
|
21
26
|
bin, err = filepath.Abs(bin)
|
|
@@ -24,20 +29,30 @@ func FindBinaryNextToMe(binName string) (string, error) {
|
|
|
24
29
|
}
|
|
25
30
|
|
|
26
31
|
// Check that the binary exists.
|
|
27
|
-
if _, err
|
|
32
|
+
if _, err = os.Stat(bin); err != nil {
|
|
28
33
|
return "", err
|
|
29
34
|
}
|
|
35
|
+
|
|
30
36
|
return bin, nil
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
//
|
|
39
|
+
// FindCosmicSwingsetBinary looks for binName in the following locations:
|
|
34
40
|
// 1. The executable's directory
|
|
35
|
-
// 2.
|
|
41
|
+
// 2. Walking up to ../../cosmic-swingset/src/entrypoint.js
|
|
42
|
+
// 3. Walking up to ../../../packages/cosmic-swingset/src/entrypoint.js
|
|
43
|
+
// 4. The system PATH
|
|
36
44
|
//
|
|
37
45
|
// It returns the absolute filename for binName if it is found, otherwise an
|
|
38
46
|
// error.
|
|
39
|
-
func
|
|
40
|
-
|
|
47
|
+
func FindCosmicSwingsetBinary() (string, error) {
|
|
48
|
+
binName := "ag-chain-cosmos"
|
|
49
|
+
if binary, err := FindBinaryNextToMe(0, binName); err == nil {
|
|
50
|
+
return binary, nil
|
|
51
|
+
}
|
|
52
|
+
if binary, err := FindBinaryNextToMe(2, "cosmic-swingset", "src", "entrypoint.js"); err == nil {
|
|
53
|
+
return binary, nil
|
|
54
|
+
}
|
|
55
|
+
if binary, err := FindBinaryNextToMe(3, "packages", "cosmic-swingset", "src", "entrypoint.js"); err == nil {
|
|
41
56
|
return binary, nil
|
|
42
57
|
}
|
|
43
58
|
|
package/cmd/agd/main.go
CHANGED
|
@@ -1,34 +1,157 @@
|
|
|
1
1
|
package main
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"context"
|
|
5
|
+
"errors"
|
|
6
|
+
"net/rpc"
|
|
7
|
+
"net/rpc/jsonrpc"
|
|
4
8
|
"os"
|
|
9
|
+
"os/exec"
|
|
5
10
|
"syscall"
|
|
11
|
+
"time"
|
|
6
12
|
|
|
13
|
+
"github.com/spf13/cast"
|
|
7
14
|
"github.com/tendermint/tendermint/libs/log"
|
|
8
15
|
|
|
9
16
|
gaia "github.com/Agoric/agoric-sdk/golang/cosmos/app"
|
|
10
17
|
"github.com/Agoric/agoric-sdk/golang/cosmos/daemon"
|
|
11
18
|
daemoncmd "github.com/Agoric/agoric-sdk/golang/cosmos/daemon/cmd"
|
|
19
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm"
|
|
20
|
+
"github.com/Agoric/agoric-sdk/golang/cosmos/vm/jsonrpcconn"
|
|
21
|
+
servertypes "github.com/cosmos/cosmos-sdk/server/types"
|
|
12
22
|
)
|
|
13
23
|
|
|
24
|
+
// TerminateSubprocessGracePeriod is how long we wait between closing the pipe
|
|
25
|
+
// waiting for it to exit, then sending a termination signal.
|
|
26
|
+
const TerminateSubprocessGracePeriod = 3 * time.Second
|
|
27
|
+
|
|
28
|
+
// KillSubprocessGracePeriod is how long we wait between sending a subprocess a
|
|
29
|
+
// termination signal, waiting for it to exit, then killing it.
|
|
30
|
+
const KillSubprocessGracePeriod = 5 * time.Second
|
|
31
|
+
|
|
32
|
+
// makeShutdown returns a function that terminates the vm.
|
|
33
|
+
func makeShutdown(cmd *exec.Cmd, writer *os.File) func() error {
|
|
34
|
+
return func() error {
|
|
35
|
+
// Stop talking to the subprocess.
|
|
36
|
+
_ = writer.Close()
|
|
37
|
+
go func() {
|
|
38
|
+
// Wait a bit.
|
|
39
|
+
time.Sleep(TerminateSubprocessGracePeriod)
|
|
40
|
+
// Then punch it in the shoulder.
|
|
41
|
+
_ = cmd.Process.Signal(os.Interrupt)
|
|
42
|
+
// Wait a bit.
|
|
43
|
+
time.Sleep(KillSubprocessGracePeriod)
|
|
44
|
+
// Then blow it away.
|
|
45
|
+
_ = cmd.Process.Kill()
|
|
46
|
+
}()
|
|
47
|
+
// Wait for it to keel over.
|
|
48
|
+
return cmd.Wait()
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// main is the entry point of the agd daemon. It determines whether to
|
|
53
|
+
// initialize JSON-RPC communications with the separate `--split-vm` VM process,
|
|
54
|
+
// or just to give up control entirely to another binary.
|
|
14
55
|
func main() {
|
|
15
|
-
|
|
16
|
-
|
|
56
|
+
var vmClient *rpc.Client
|
|
57
|
+
var shutdown func() error
|
|
58
|
+
|
|
59
|
+
nodePort := 1
|
|
60
|
+
var sendToNode vm.Sender = func(ctx context.Context, needReply bool, jsonRequest string) (jsonReply string, err error) {
|
|
61
|
+
if vmClient == nil {
|
|
62
|
+
return "", errors.New("sendToVM called without VM client set up")
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if jsonRequest == "shutdown" {
|
|
66
|
+
// We could ask nicely, but don't bother.
|
|
67
|
+
if shutdown != nil {
|
|
68
|
+
return "", shutdown()
|
|
69
|
+
}
|
|
70
|
+
return "", nil
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
msg := vm.Message{
|
|
74
|
+
Port: nodePort,
|
|
75
|
+
NeedsReply: needReply,
|
|
76
|
+
Data: jsonRequest,
|
|
77
|
+
}
|
|
78
|
+
var reply string
|
|
79
|
+
err = vmClient.Call(vm.ReceiveMessageMethod, msg, &reply)
|
|
80
|
+
return reply, err
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exitCode := 0
|
|
84
|
+
launchVM := func(agdServer *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
17
85
|
args := []string{"ag-chain-cosmos", "--home", gaia.DefaultNodeHome}
|
|
18
86
|
args = append(args, os.Args[1:]...)
|
|
19
87
|
|
|
20
|
-
|
|
88
|
+
binary := cast.ToString(appOpts.Get(daemoncmd.FlagSplitVm))
|
|
89
|
+
if binary == "" {
|
|
90
|
+
binary, lookErr := FindCosmicSwingsetBinary()
|
|
91
|
+
if lookErr != nil {
|
|
92
|
+
return lookErr
|
|
93
|
+
}
|
|
21
94
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
95
|
+
// We completely delegate to our default app for running the actual chain.
|
|
96
|
+
logger.Info("agd delegating to JS executable", "binary", binary, "args", args)
|
|
97
|
+
return syscall.Exec(binary, args, os.Environ())
|
|
25
98
|
}
|
|
26
99
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
100
|
+
// Split the execution between us and the VM.
|
|
101
|
+
agdFromVm, vmToAgd, err := os.Pipe()
|
|
102
|
+
if err != nil {
|
|
103
|
+
return err
|
|
104
|
+
}
|
|
105
|
+
vmFromAgd, agdToVm, err := os.Pipe()
|
|
106
|
+
if err != nil {
|
|
107
|
+
return err
|
|
30
108
|
}
|
|
109
|
+
|
|
110
|
+
// Start the command running, then continue.
|
|
111
|
+
args[0] = binary
|
|
112
|
+
cmd := NewVMCommand(logger, binary, args, vmFromAgd, vmToAgd)
|
|
113
|
+
shutdown = makeShutdown(cmd, agdToVm)
|
|
114
|
+
|
|
115
|
+
if err := cmd.Start(); err != nil {
|
|
116
|
+
return err
|
|
117
|
+
}
|
|
118
|
+
if vmFromAgd.Close() != nil {
|
|
119
|
+
return err
|
|
120
|
+
}
|
|
121
|
+
if vmToAgd.Close() != nil {
|
|
122
|
+
return err
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// Multiplex bidirectional JSON-RPC over the pipes.
|
|
126
|
+
agvmConn := jsonrpcconn.NewConn(agdFromVm, agdToVm)
|
|
127
|
+
clientConn, serverConn := jsonrpcconn.ClientServerConn(agvmConn)
|
|
128
|
+
|
|
129
|
+
// Set up the VM server.
|
|
130
|
+
vmServer := rpc.NewServer()
|
|
131
|
+
if err := vmServer.RegisterName("agd", agdServer); err != nil {
|
|
132
|
+
return err
|
|
133
|
+
}
|
|
134
|
+
go vmServer.ServeCodec(jsonrpc.NewServerCodec(serverConn))
|
|
135
|
+
|
|
136
|
+
// Set up the VM client.
|
|
137
|
+
vmClient = jsonrpc.NewClient(clientConn)
|
|
138
|
+
|
|
139
|
+
go func() {
|
|
140
|
+
// Premature exit from `agd start` should exit the process.
|
|
141
|
+
_ = cmd.Wait()
|
|
142
|
+
os.Exit(exitCode)
|
|
143
|
+
}()
|
|
144
|
+
|
|
145
|
+
return nil
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
daemoncmd.OnExportHook = launchVM
|
|
149
|
+
daemoncmd.OnStartHook = func(agdServer *vm.AgdServer, logger log.Logger, appOpts servertypes.AppOptions) error {
|
|
150
|
+
// We tried running start, which should never exit, so exit with non-zero
|
|
151
|
+
// code if we do.
|
|
152
|
+
exitCode = 99
|
|
153
|
+
return launchVM(agdServer, logger, appOpts)
|
|
31
154
|
}
|
|
32
155
|
|
|
33
|
-
daemon.RunWithController(
|
|
156
|
+
daemon.RunWithController(sendToNode)
|
|
34
157
|
}
|