@agoric/cosmos 0.35.0-u12.0 → 0.35.0-u13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/Makefile +1 -1
- package/ante/ante.go +2 -2
- package/ante/inbound_test.go +8 -0
- package/app/app.go +44 -45
- package/app/export.go +0 -3
- package/app/sim_test.go +4 -4
- package/daemon/cmd/root.go +0 -2
- package/git-revision.txt +1 -1
- package/go.mod +56 -46
- package/go.sum +453 -154
- package/package.json +2 -2
- package/x/lien/keeper/account.go +13 -8
- package/x/swingset/keeper/keeper.go +39 -0
- package/x/swingset/keeper/migrations.go +7 -2
- package/x/swingset/keeper/msg_server.go +52 -5
- package/x/swingset/types/default-params.go +22 -16
- package/x/swingset/types/expected_keepers.go +11 -0
- package/x/swingset/types/msgs.go +43 -2
- package/x/swingset/types/params.go +74 -0
- package/x/swingset/types/params_test.go +116 -0
- package/x/vibc/ibc.go +25 -25
- package/x/vibc/keeper/keeper.go +4 -4
- package/x/vibc/types/expected_keepers.go +3 -3
- package/x/vibc/types/msgs.go +1 -1
- package/x/vibc/types/msgs.pb.go +1 -1
- package/x/vstorage/keeper/querier_test.go +112 -0
- package/x/swingset/legacy/v32/params.go +0 -37
- package/x/swingset/legacy/v32/params_test.go +0 -133
package/x/vibc/keeper/keeper.go
CHANGED
|
@@ -9,10 +9,10 @@ import (
|
|
|
9
9
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
10
10
|
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
|
|
11
11
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
12
|
-
channeltypes "github.com/cosmos/ibc-go/
|
|
13
|
-
porttypes "github.com/cosmos/ibc-go/
|
|
14
|
-
host "github.com/cosmos/ibc-go/
|
|
15
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
12
|
+
channeltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
|
|
13
|
+
porttypes "github.com/cosmos/ibc-go/v4/modules/core/05-port/types"
|
|
14
|
+
host "github.com/cosmos/ibc-go/v4/modules/core/24-host"
|
|
15
|
+
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
|
|
16
16
|
|
|
17
17
|
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
|
18
18
|
|
|
@@ -3,9 +3,9 @@ package types
|
|
|
3
3
|
import (
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
capability "github.com/cosmos/cosmos-sdk/x/capability/types"
|
|
6
|
-
connection "github.com/cosmos/ibc-go/
|
|
7
|
-
channel "github.com/cosmos/ibc-go/
|
|
8
|
-
ibcexported "github.com/cosmos/ibc-go/
|
|
6
|
+
connection "github.com/cosmos/ibc-go/v4/modules/core/03-connection/types"
|
|
7
|
+
channel "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
|
|
8
|
+
ibcexported "github.com/cosmos/ibc-go/v4/modules/core/exported"
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
// ChannelKeeper defines the expected IBC channel keeper
|
package/x/vibc/types/msgs.go
CHANGED
|
@@ -4,7 +4,7 @@ import (
|
|
|
4
4
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
5
5
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
6
6
|
|
|
7
|
-
chanTypes "github.com/cosmos/ibc-go/
|
|
7
|
+
chanTypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
|
|
8
8
|
)
|
|
9
9
|
|
|
10
10
|
const RouterKey = ModuleName // this was defined in your key.go file
|
package/x/vibc/types/msgs.pb.go
CHANGED
|
@@ -7,7 +7,7 @@ import (
|
|
|
7
7
|
context "context"
|
|
8
8
|
fmt "fmt"
|
|
9
9
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
-
types "github.com/cosmos/ibc-go/
|
|
10
|
+
types "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
|
|
11
11
|
_ "github.com/gogo/protobuf/gogoproto"
|
|
12
12
|
grpc1 "github.com/gogo/protobuf/grpc"
|
|
13
13
|
proto "github.com/gogo/protobuf/proto"
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
package keeper
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"testing"
|
|
6
|
+
|
|
7
|
+
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
8
|
+
|
|
9
|
+
abci "github.com/tendermint/tendermint/abci/types"
|
|
10
|
+
|
|
11
|
+
"github.com/cosmos/cosmos-sdk/codec"
|
|
12
|
+
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
func TestQuerier(t *testing.T) {
|
|
16
|
+
testKit := makeTestKit()
|
|
17
|
+
ctx, keeper := testKit.ctx, testKit.vstorageKeeper
|
|
18
|
+
legacyQuerierCdc := codec.NewAminoCodec(codec.NewLegacyAmino())
|
|
19
|
+
querier := NewQuerier(keeper, legacyQuerierCdc.LegacyAmino)
|
|
20
|
+
|
|
21
|
+
// Populate mock data
|
|
22
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("foo.bar", "42"))
|
|
23
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("foo.baz", "hello"))
|
|
24
|
+
|
|
25
|
+
type testCase struct {
|
|
26
|
+
label string
|
|
27
|
+
path []string
|
|
28
|
+
expected []byte
|
|
29
|
+
err *sdkerrors.Error
|
|
30
|
+
}
|
|
31
|
+
testCases := []testCase{}
|
|
32
|
+
|
|
33
|
+
// Test invalid endpoint
|
|
34
|
+
testCases = append(testCases, []testCase{
|
|
35
|
+
{label: "invalid endpoint",
|
|
36
|
+
path: []string{"foo"},
|
|
37
|
+
err: sdkerrors.ErrUnknownRequest,
|
|
38
|
+
},
|
|
39
|
+
}...)
|
|
40
|
+
|
|
41
|
+
// Test invalid arguments to valid data and children endpoints
|
|
42
|
+
for _, endpoint := range []string{"data", "children"} {
|
|
43
|
+
testCases = append(testCases, []testCase{
|
|
44
|
+
{label: endpoint + ": no entry path",
|
|
45
|
+
path: []string{endpoint},
|
|
46
|
+
err: sdkerrors.ErrInvalidRequest,
|
|
47
|
+
},
|
|
48
|
+
{label: endpoint + ": too many segments",
|
|
49
|
+
path: []string{endpoint, "foo", "bar"},
|
|
50
|
+
err: sdkerrors.ErrInvalidRequest,
|
|
51
|
+
},
|
|
52
|
+
{label: endpoint + ": invalid path",
|
|
53
|
+
path: []string{endpoint, ".", ""},
|
|
54
|
+
err: sdkerrors.ErrInvalidRequest,
|
|
55
|
+
},
|
|
56
|
+
}...)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Test data endpoint with valid vstorage path
|
|
60
|
+
testCases = append(testCases, []testCase{
|
|
61
|
+
{label: "data: non-existent path",
|
|
62
|
+
path: []string{"data", "bar"},
|
|
63
|
+
// DO NOT CHANGE
|
|
64
|
+
// The UI and CLI check for the specific cosmos-sdk error code & codespace
|
|
65
|
+
err: sdkerrors.ErrNotFound,
|
|
66
|
+
},
|
|
67
|
+
{label: "data: path with no data",
|
|
68
|
+
path: []string{"data", "foo"},
|
|
69
|
+
// DO NOT CHANGE
|
|
70
|
+
// The UI and CLI check for the specific cosmos-sdk error code & codespace
|
|
71
|
+
err: sdkerrors.ErrNotFound,
|
|
72
|
+
},
|
|
73
|
+
{label: "data: path with data",
|
|
74
|
+
path: []string{"data", "foo.bar"},
|
|
75
|
+
expected: []byte("{\n \"value\": \"42\"\n}"),
|
|
76
|
+
},
|
|
77
|
+
}...)
|
|
78
|
+
|
|
79
|
+
// Ensure stability of cosmos-sdk error codes
|
|
80
|
+
if codespace, code, _ := sdkerrors.ABCIInfo(sdkerrors.ErrNotFound, true); codespace != "sdk" || code != 38 {
|
|
81
|
+
t.Errorf("cosmos-sdk ErrNotFound has codespace %s, code %d, expected sdk/38", codespace, code)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Test children endpoint with valid vstorage path
|
|
85
|
+
testCases = append(testCases, []testCase{
|
|
86
|
+
{label: "children: non-existent path",
|
|
87
|
+
path: []string{"children", "bar"},
|
|
88
|
+
expected: []byte("{\n \"children\": []\n}"),
|
|
89
|
+
},
|
|
90
|
+
{label: "children: path with no children",
|
|
91
|
+
path: []string{"children", "foo.bar"},
|
|
92
|
+
expected: []byte("{\n \"children\": []\n}"),
|
|
93
|
+
},
|
|
94
|
+
{label: "children: path with children",
|
|
95
|
+
path: []string{"children", "foo"},
|
|
96
|
+
expected: []byte("{\n \"children\": [\n \"bar\",\n \"baz\"\n ]\n}"),
|
|
97
|
+
},
|
|
98
|
+
}...)
|
|
99
|
+
|
|
100
|
+
for _, desc := range testCases {
|
|
101
|
+
res, err := querier(ctx, desc.path, abci.RequestQuery{})
|
|
102
|
+
if desc.err != nil {
|
|
103
|
+
if err == nil {
|
|
104
|
+
t.Errorf("%s: got no error, want error %q", desc.label, *desc.err)
|
|
105
|
+
} else if codespace, code, _ := sdkerrors.ABCIInfo(err, true); codespace != desc.err.Codespace() || code != desc.err.ABCICode() {
|
|
106
|
+
t.Errorf("%s: got error %v, want error %q", desc.label, err, *desc.err)
|
|
107
|
+
}
|
|
108
|
+
} else if !bytes.Equal(res, desc.expected) {
|
|
109
|
+
t.Errorf("%s: wrong result: %#v, expected %#v", desc.label, string(res), string(desc.expected))
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
package v32
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"fmt"
|
|
5
|
-
|
|
6
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
7
|
-
)
|
|
8
|
-
|
|
9
|
-
// UpdateParams performs the parameter updates to migrate to version 2,
|
|
10
|
-
// returning the updated params or an error.
|
|
11
|
-
func UpdateParams(params types.Params) (types.Params, error) {
|
|
12
|
-
newBpu, err := addStorageBeanCost(params.BeansPerUnit)
|
|
13
|
-
if err != nil {
|
|
14
|
-
return params, err
|
|
15
|
-
}
|
|
16
|
-
params.BeansPerUnit = newBpu
|
|
17
|
-
return params, nil
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// addStorageBeanCost adds the default beans per storage byte cost,
|
|
21
|
-
// if it's not in the list of bean costs already, returning the possibly-updated list.
|
|
22
|
-
// or an error if there's no default storage cost.
|
|
23
|
-
func addStorageBeanCost(bpu []types.StringBeans) ([]types.StringBeans, error) {
|
|
24
|
-
for _, ob := range bpu {
|
|
25
|
-
if ob.Key == types.BeansPerStorageByte {
|
|
26
|
-
// success if there's already an entry
|
|
27
|
-
return bpu, nil
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
defaultParams := types.DefaultParams()
|
|
31
|
-
for _, b := range defaultParams.BeansPerUnit {
|
|
32
|
-
if b.Key == types.BeansPerStorageByte {
|
|
33
|
-
return append(bpu, b), nil
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return bpu, fmt.Errorf("no beans per storage byte in default params %v", defaultParams)
|
|
37
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
package v32
|
|
2
|
-
|
|
3
|
-
import (
|
|
4
|
-
"reflect"
|
|
5
|
-
"testing"
|
|
6
|
-
|
|
7
|
-
"github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
|
|
8
|
-
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
9
|
-
)
|
|
10
|
-
|
|
11
|
-
type beans = types.StringBeans
|
|
12
|
-
|
|
13
|
-
func TestAddStorageBeanCost(t *testing.T) {
|
|
14
|
-
var defaultStorageCost beans
|
|
15
|
-
for _, b := range types.DefaultParams().BeansPerUnit {
|
|
16
|
-
if b.Key == types.BeansPerStorageByte {
|
|
17
|
-
defaultStorageCost = b
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if defaultStorageCost.Key == "" {
|
|
21
|
-
t.Fatalf("no beans per storage byte in default params")
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
for _, tt := range []struct {
|
|
25
|
-
name string
|
|
26
|
-
in []beans
|
|
27
|
-
want []beans
|
|
28
|
-
}{
|
|
29
|
-
{
|
|
30
|
-
name: "empty",
|
|
31
|
-
in: []beans{},
|
|
32
|
-
want: []beans{defaultStorageCost},
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
name: "already_only_same",
|
|
36
|
-
in: []beans{defaultStorageCost},
|
|
37
|
-
want: []beans{defaultStorageCost},
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
name: "already_only_different",
|
|
41
|
-
in: []beans{types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(123))},
|
|
42
|
-
want: []beans{types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(123))},
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
name: "already_same",
|
|
46
|
-
in: []beans{
|
|
47
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
48
|
-
defaultStorageCost,
|
|
49
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
50
|
-
},
|
|
51
|
-
want: []beans{
|
|
52
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
53
|
-
defaultStorageCost,
|
|
54
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
name: "already_different",
|
|
59
|
-
in: []beans{
|
|
60
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
61
|
-
types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(789)),
|
|
62
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
63
|
-
},
|
|
64
|
-
want: []beans{
|
|
65
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
66
|
-
types.NewStringBeans(types.BeansPerStorageByte, sdk.NewUint(789)),
|
|
67
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
name: "missing",
|
|
72
|
-
in: []beans{
|
|
73
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
74
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
75
|
-
},
|
|
76
|
-
want: []beans{
|
|
77
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
78
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
79
|
-
defaultStorageCost,
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
} {
|
|
83
|
-
t.Run(tt.name, func(t *testing.T) {
|
|
84
|
-
got, err := addStorageBeanCost(tt.in)
|
|
85
|
-
if err != nil {
|
|
86
|
-
t.Errorf("got error %v", err)
|
|
87
|
-
} else if !reflect.DeepEqual(got, tt.want) {
|
|
88
|
-
t.Errorf("want %v, got %v", tt.want, got)
|
|
89
|
-
}
|
|
90
|
-
})
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
func TestUpdateParams(t *testing.T) {
|
|
95
|
-
var defaultStorageCost beans
|
|
96
|
-
for _, b := range types.DefaultParams().BeansPerUnit {
|
|
97
|
-
if b.Key == types.BeansPerStorageByte {
|
|
98
|
-
defaultStorageCost = b
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if defaultStorageCost.Key == "" {
|
|
102
|
-
t.Fatalf("no beans per storage byte in default params")
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
in := types.Params{
|
|
106
|
-
BeansPerUnit: []beans{
|
|
107
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
108
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
109
|
-
},
|
|
110
|
-
BootstrapVatConfig: "baz",
|
|
111
|
-
FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
|
|
112
|
-
PowerFlagFees: types.DefaultPowerFlagFees,
|
|
113
|
-
QueueMax: types.DefaultQueueMax,
|
|
114
|
-
}
|
|
115
|
-
want := types.Params{
|
|
116
|
-
BeansPerUnit: []beans{
|
|
117
|
-
types.NewStringBeans("foo", sdk.NewUint(123)),
|
|
118
|
-
types.NewStringBeans("bar", sdk.NewUint(456)),
|
|
119
|
-
defaultStorageCost,
|
|
120
|
-
},
|
|
121
|
-
BootstrapVatConfig: "baz",
|
|
122
|
-
FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
|
|
123
|
-
PowerFlagFees: types.DefaultPowerFlagFees,
|
|
124
|
-
QueueMax: types.DefaultQueueMax,
|
|
125
|
-
}
|
|
126
|
-
got, err := UpdateParams(in)
|
|
127
|
-
if err != nil {
|
|
128
|
-
t.Fatalf("UpdateParam error %v", err)
|
|
129
|
-
}
|
|
130
|
-
if !reflect.DeepEqual(got, want) {
|
|
131
|
-
t.Errorf("got %v, want %v", got, want)
|
|
132
|
-
}
|
|
133
|
-
}
|