@agoric/cosmos 0.33.0 → 0.33.1-dev-d32a66a.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/Makefile +1 -1
- package/app/app.go +109 -16
- package/app/const.go +2 -2
- package/daemon/cmd/root.go +8 -13
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +10 -0
- package/proto/agoric/swingset/swingset.proto +14 -0
- package/x/swingset/abci.go +24 -17
- package/x/swingset/alias.go +1 -0
- package/x/swingset/client/cli/tx.go +18 -0
- package/x/swingset/genesis.go +11 -6
- package/x/swingset/keeper/keeper.go +131 -56
- package/x/swingset/keeper/migrations.go +27 -0
- package/x/swingset/keeper/msg_server.go +23 -6
- package/x/swingset/keeper/proposal.go +1 -1
- package/x/swingset/keeper/querier.go +3 -3
- package/x/swingset/keeper/snapshotter.go +491 -0
- package/x/swingset/keeper/snapshotter_test.go +185 -0
- package/x/swingset/legacy/v32/params.go +37 -0
- package/x/swingset/legacy/v32/params_test.go +133 -0
- package/x/swingset/module.go +6 -1
- package/x/swingset/types/default-params.go +5 -2
- package/x/swingset/types/expected_keepers.go +1 -0
- package/x/swingset/types/msgs.go +156 -10
- package/x/swingset/types/msgs.pb.go +142 -47
- package/x/swingset/types/msgs_test.go +174 -0
- package/x/swingset/types/swingset.pb.go +280 -51
- package/x/swingset/types/types.go +1 -1
- package/x/vbank/README.md +1 -1
- package/x/vbank/keeper/keeper.go +15 -1
- package/x/vbank/module.go +13 -1
- package/x/vbank/types/expected_keepers.go +3 -1
- package/x/vbank/vbank.go +8 -0
- package/x/vbank/vbank_test.go +70 -9
- package/x/vstorage/keeper/grpc_query.go +2 -2
- package/x/vstorage/keeper/keeper.go +269 -38
- package/x/vstorage/keeper/keeper_test.go +162 -17
- package/x/vstorage/keeper/querier.go +4 -4
- package/x/vstorage/module.go +2 -0
- package/x/vstorage/types/path_keys.go +10 -3
- package/x/vstorage/types/types.go +66 -0
- package/x/vstorage/vstorage.go +118 -25
- package/x/vstorage/vstorage_test.go +297 -0
|
@@ -431,6 +431,11 @@ var xxx_messageInfo_MsgProvisionResponse proto.InternalMessageInfo
|
|
|
431
431
|
type MsgInstallBundle struct {
|
|
432
432
|
Bundle string `protobuf:"bytes,1,opt,name=bundle,proto3" json:"bundle" yaml:"bundle"`
|
|
433
433
|
Submitter github_com_cosmos_cosmos_sdk_types.AccAddress `protobuf:"bytes,2,opt,name=submitter,proto3,casttype=github.com/cosmos/cosmos-sdk/types.AccAddress" json:"submitter" yaml:"submitter"`
|
|
434
|
+
// Either bundle or compressed_bundle will be set.
|
|
435
|
+
// Default compression algorithm is gzip.
|
|
436
|
+
CompressedBundle []byte `protobuf:"bytes,3,opt,name=compressed_bundle,json=compressedBundle,proto3" json:"compressedBundle" yaml:"bcompressedBndle"`
|
|
437
|
+
// Size in bytes of uncompression of compressed_bundle.
|
|
438
|
+
UncompressedSize int64 `protobuf:"varint,4,opt,name=uncompressed_size,json=uncompressedSize,proto3" json:"uncompressedSize"`
|
|
434
439
|
}
|
|
435
440
|
|
|
436
441
|
func (m *MsgInstallBundle) Reset() { *m = MsgInstallBundle{} }
|
|
@@ -480,6 +485,20 @@ func (m *MsgInstallBundle) GetSubmitter() github_com_cosmos_cosmos_sdk_types.Acc
|
|
|
480
485
|
return nil
|
|
481
486
|
}
|
|
482
487
|
|
|
488
|
+
func (m *MsgInstallBundle) GetCompressedBundle() []byte {
|
|
489
|
+
if m != nil {
|
|
490
|
+
return m.CompressedBundle
|
|
491
|
+
}
|
|
492
|
+
return nil
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
func (m *MsgInstallBundle) GetUncompressedSize() int64 {
|
|
496
|
+
if m != nil {
|
|
497
|
+
return m.UncompressedSize
|
|
498
|
+
}
|
|
499
|
+
return 0
|
|
500
|
+
}
|
|
501
|
+
|
|
483
502
|
// MsgInstallBundleResponse is an empty acknowledgement that an install bundle
|
|
484
503
|
// message has been queued for the SwingSet kernel's consideration.
|
|
485
504
|
type MsgInstallBundleResponse struct {
|
|
@@ -534,53 +553,57 @@ func init() {
|
|
|
534
553
|
func init() { proto.RegisterFile("agoric/swingset/msgs.proto", fileDescriptor_788baa062b181a57) }
|
|
535
554
|
|
|
536
555
|
var fileDescriptor_788baa062b181a57 = []byte{
|
|
537
|
-
//
|
|
538
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4,
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
556
|
+
// 789 bytes of a gzipped FileDescriptorProto
|
|
557
|
+
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcf, 0x6f, 0xe3, 0x44,
|
|
558
|
+
0x14, 0x8e, 0xe3, 0x50, 0x36, 0xaf, 0xd9, 0x6d, 0x63, 0x95, 0xad, 0xd7, 0x0b, 0x99, 0xac, 0xa5,
|
|
559
|
+
0x15, 0x01, 0xd4, 0x44, 0xb0, 0xb7, 0xed, 0x29, 0x16, 0x42, 0x5a, 0xa4, 0xa0, 0xc5, 0x2b, 0x84,
|
|
560
|
+
0x54, 0x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, 0xf9, 0xbf, 0xd2, 0x45, 0x49,
|
|
602
|
+
0xe3, 0xab, 0xdf, 0xe6, 0x1d, 0xe9, 0x6a, 0xde, 0x91, 0xae, 0xe7, 0x1d, 0xe9, 0xc7, 0x9b, 0x4e,
|
|
603
|
+
0xed, 0xea, 0xa6, 0x53, 0xfb, 0xfd, 0xa6, 0x53, 0x3b, 0x3a, 0x5c, 0x98, 0xf9, 0xa1, 0xf8, 0x20,
|
|
604
|
+
0x10, 0x15, 0xf9, 0xcc, 0x3b, 0xc4, 0xb3, 0x02, 0xa7, 0xb8, 0x0c, 0xdf, 0x57, 0xdf, 0x0a, 0xfc,
|
|
605
|
+
0x32, 0x8c, 0xb7, 0xf8, 0x67, 0xc0, 0x8b, 0xbf, 0x03, 0x00, 0x00, 0xff, 0xff, 0x99, 0x11, 0x18,
|
|
606
|
+
0xbe, 0x4b, 0x08, 0x00, 0x00,
|
|
584
607
|
}
|
|
585
608
|
|
|
586
609
|
// Reference imports to suppress errors if they are not otherwise used.
|
|
@@ -1118,6 +1141,18 @@ func (m *MsgInstallBundle) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
|
1118
1141
|
_ = i
|
|
1119
1142
|
var l int
|
|
1120
1143
|
_ = l
|
|
1144
|
+
if m.UncompressedSize != 0 {
|
|
1145
|
+
i = encodeVarintMsgs(dAtA, i, uint64(m.UncompressedSize))
|
|
1146
|
+
i--
|
|
1147
|
+
dAtA[i] = 0x20
|
|
1148
|
+
}
|
|
1149
|
+
if len(m.CompressedBundle) > 0 {
|
|
1150
|
+
i -= len(m.CompressedBundle)
|
|
1151
|
+
copy(dAtA[i:], m.CompressedBundle)
|
|
1152
|
+
i = encodeVarintMsgs(dAtA, i, uint64(len(m.CompressedBundle)))
|
|
1153
|
+
i--
|
|
1154
|
+
dAtA[i] = 0x1a
|
|
1155
|
+
}
|
|
1121
1156
|
if len(m.Submitter) > 0 {
|
|
1122
1157
|
i -= len(m.Submitter)
|
|
1123
1158
|
copy(dAtA[i:], m.Submitter)
|
|
@@ -1309,6 +1344,13 @@ func (m *MsgInstallBundle) Size() (n int) {
|
|
|
1309
1344
|
if l > 0 {
|
|
1310
1345
|
n += 1 + l + sovMsgs(uint64(l))
|
|
1311
1346
|
}
|
|
1347
|
+
l = len(m.CompressedBundle)
|
|
1348
|
+
if l > 0 {
|
|
1349
|
+
n += 1 + l + sovMsgs(uint64(l))
|
|
1350
|
+
}
|
|
1351
|
+
if m.UncompressedSize != 0 {
|
|
1352
|
+
n += 1 + sovMsgs(uint64(m.UncompressedSize))
|
|
1353
|
+
}
|
|
1312
1354
|
return n
|
|
1313
1355
|
}
|
|
1314
1356
|
|
|
@@ -2247,6 +2289,59 @@ func (m *MsgInstallBundle) Unmarshal(dAtA []byte) error {
|
|
|
2247
2289
|
m.Submitter = []byte{}
|
|
2248
2290
|
}
|
|
2249
2291
|
iNdEx = postIndex
|
|
2292
|
+
case 3:
|
|
2293
|
+
if wireType != 2 {
|
|
2294
|
+
return fmt.Errorf("proto: wrong wireType = %d for field CompressedBundle", wireType)
|
|
2295
|
+
}
|
|
2296
|
+
var byteLen int
|
|
2297
|
+
for shift := uint(0); ; shift += 7 {
|
|
2298
|
+
if shift >= 64 {
|
|
2299
|
+
return ErrIntOverflowMsgs
|
|
2300
|
+
}
|
|
2301
|
+
if iNdEx >= l {
|
|
2302
|
+
return io.ErrUnexpectedEOF
|
|
2303
|
+
}
|
|
2304
|
+
b := dAtA[iNdEx]
|
|
2305
|
+
iNdEx++
|
|
2306
|
+
byteLen |= int(b&0x7F) << shift
|
|
2307
|
+
if b < 0x80 {
|
|
2308
|
+
break
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
if byteLen < 0 {
|
|
2312
|
+
return ErrInvalidLengthMsgs
|
|
2313
|
+
}
|
|
2314
|
+
postIndex := iNdEx + byteLen
|
|
2315
|
+
if postIndex < 0 {
|
|
2316
|
+
return ErrInvalidLengthMsgs
|
|
2317
|
+
}
|
|
2318
|
+
if postIndex > l {
|
|
2319
|
+
return io.ErrUnexpectedEOF
|
|
2320
|
+
}
|
|
2321
|
+
m.CompressedBundle = append(m.CompressedBundle[:0], dAtA[iNdEx:postIndex]...)
|
|
2322
|
+
if m.CompressedBundle == nil {
|
|
2323
|
+
m.CompressedBundle = []byte{}
|
|
2324
|
+
}
|
|
2325
|
+
iNdEx = postIndex
|
|
2326
|
+
case 4:
|
|
2327
|
+
if wireType != 0 {
|
|
2328
|
+
return fmt.Errorf("proto: wrong wireType = %d for field UncompressedSize", wireType)
|
|
2329
|
+
}
|
|
2330
|
+
m.UncompressedSize = 0
|
|
2331
|
+
for shift := uint(0); ; shift += 7 {
|
|
2332
|
+
if shift >= 64 {
|
|
2333
|
+
return ErrIntOverflowMsgs
|
|
2334
|
+
}
|
|
2335
|
+
if iNdEx >= l {
|
|
2336
|
+
return io.ErrUnexpectedEOF
|
|
2337
|
+
}
|
|
2338
|
+
b := dAtA[iNdEx]
|
|
2339
|
+
iNdEx++
|
|
2340
|
+
m.UncompressedSize |= int64(b&0x7F) << shift
|
|
2341
|
+
if b < 0x80 {
|
|
2342
|
+
break
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2250
2345
|
default:
|
|
2251
2346
|
iNdEx = preIndex
|
|
2252
2347
|
skippy, err := skipMsgs(dAtA[iNdEx:])
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
package types
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"bytes"
|
|
5
|
+
"math"
|
|
4
6
|
"testing"
|
|
5
7
|
|
|
6
8
|
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
|
7
9
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
10
|
+
"github.com/gogo/protobuf/proto"
|
|
8
11
|
)
|
|
9
12
|
|
|
10
13
|
var (
|
|
@@ -88,3 +91,174 @@ func TestWalletSpendAction(t *testing.T) {
|
|
|
88
91
|
})
|
|
89
92
|
}
|
|
90
93
|
}
|
|
94
|
+
|
|
95
|
+
func TestInstallBundle_ValidateBasic(t *testing.T) {
|
|
96
|
+
for _, tt := range []struct {
|
|
97
|
+
name string
|
|
98
|
+
msg *MsgInstallBundle
|
|
99
|
+
shouldErr bool
|
|
100
|
+
}{
|
|
101
|
+
{
|
|
102
|
+
name: "empty",
|
|
103
|
+
msg: &MsgInstallBundle{},
|
|
104
|
+
shouldErr: true,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "no bundle",
|
|
108
|
+
msg: NewMsgInstallBundle("", addr),
|
|
109
|
+
shouldErr: true,
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
name: "uncompressed",
|
|
113
|
+
msg: NewMsgInstallBundle("true", addr),
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
name: "compressed",
|
|
117
|
+
msg: &MsgInstallBundle{
|
|
118
|
+
Submitter: addr,
|
|
119
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
120
|
+
UncompressedSize: 4,
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
name: "both",
|
|
125
|
+
msg: &MsgInstallBundle{
|
|
126
|
+
Bundle: "foo",
|
|
127
|
+
Submitter: addr,
|
|
128
|
+
CompressedBundle: []byte{1},
|
|
129
|
+
},
|
|
130
|
+
shouldErr: true,
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
name: "zero size",
|
|
134
|
+
msg: &MsgInstallBundle{
|
|
135
|
+
Submitter: addr,
|
|
136
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
137
|
+
},
|
|
138
|
+
shouldErr: true,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
name: "negative size",
|
|
142
|
+
msg: &MsgInstallBundle{
|
|
143
|
+
Submitter: addr,
|
|
144
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
145
|
+
UncompressedSize: -4,
|
|
146
|
+
},
|
|
147
|
+
shouldErr: true,
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
name: "under limit",
|
|
151
|
+
msg: &MsgInstallBundle{
|
|
152
|
+
Submitter: addr,
|
|
153
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
154
|
+
UncompressedSize: bundleUncompressedSizeLimit - 1,
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
{
|
|
159
|
+
name: "limit",
|
|
160
|
+
msg: &MsgInstallBundle{
|
|
161
|
+
Submitter: addr,
|
|
162
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
163
|
+
UncompressedSize: bundleUncompressedSizeLimit,
|
|
164
|
+
},
|
|
165
|
+
shouldErr: true,
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "max",
|
|
169
|
+
msg: &MsgInstallBundle{
|
|
170
|
+
Submitter: addr,
|
|
171
|
+
CompressedBundle: []byte{1, 2, 3},
|
|
172
|
+
UncompressedSize: math.MaxInt64,
|
|
173
|
+
},
|
|
174
|
+
shouldErr: true,
|
|
175
|
+
},
|
|
176
|
+
} {
|
|
177
|
+
t.Run(tt.name, func(t *testing.T) {
|
|
178
|
+
err := tt.msg.ValidateBasic()
|
|
179
|
+
if err != nil && !tt.shouldErr {
|
|
180
|
+
t.Fatalf("unexpected validation error %s", err)
|
|
181
|
+
}
|
|
182
|
+
if err == nil && tt.shouldErr {
|
|
183
|
+
t.Fatalf("wanted validation error")
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
func TestInstallBundle_Compress(t *testing.T) {
|
|
190
|
+
// proto.Equal panics because of AccAddress field
|
|
191
|
+
eq := func(a, b *MsgInstallBundle) bool {
|
|
192
|
+
return a.Bundle == b.Bundle &&
|
|
193
|
+
a.Submitter.Equals(b.Submitter) &&
|
|
194
|
+
bytes.Equal(a.CompressedBundle, b.CompressedBundle) &&
|
|
195
|
+
a.UncompressedSize == b.UncompressedSize
|
|
196
|
+
}
|
|
197
|
+
text := "Lorem ipsum dolor sit amet"
|
|
198
|
+
size := len(text)
|
|
199
|
+
msg := NewMsgInstallBundle(text, addr)
|
|
200
|
+
origMsg := proto.Clone(msg).(*MsgInstallBundle)
|
|
201
|
+
err := msg.ValidateBasic()
|
|
202
|
+
if err != nil {
|
|
203
|
+
t.Fatal(err)
|
|
204
|
+
}
|
|
205
|
+
gotSize := msg.ExpectedUncompressedSize()
|
|
206
|
+
if gotSize != uint64(size) {
|
|
207
|
+
t.Errorf("want expected size %d, got %d", size, gotSize)
|
|
208
|
+
}
|
|
209
|
+
err = msg.Uncompress()
|
|
210
|
+
if err != nil {
|
|
211
|
+
t.Fatal(err)
|
|
212
|
+
}
|
|
213
|
+
if !eq(msg, origMsg) {
|
|
214
|
+
t.Errorf("noop uncompress got %+v, want %+v", *msg, origMsg)
|
|
215
|
+
}
|
|
216
|
+
err = msg.Compress()
|
|
217
|
+
if err != nil {
|
|
218
|
+
t.Fatal(err)
|
|
219
|
+
}
|
|
220
|
+
err = msg.ValidateBasic()
|
|
221
|
+
if err != nil {
|
|
222
|
+
t.Fatal(err)
|
|
223
|
+
}
|
|
224
|
+
if msg.UncompressedSize != int64(size) {
|
|
225
|
+
t.Errorf("want uncompressed size field %d, got %d", size, msg.UncompressedSize)
|
|
226
|
+
}
|
|
227
|
+
gotSize = msg.ExpectedUncompressedSize()
|
|
228
|
+
if gotSize != uint64(size) {
|
|
229
|
+
t.Errorf("want expected size %d, got %d", size, gotSize)
|
|
230
|
+
}
|
|
231
|
+
if msg.Bundle != "" {
|
|
232
|
+
t.Errorf("want empty bundle field, got %s", msg.Bundle)
|
|
233
|
+
}
|
|
234
|
+
if len(msg.CompressedBundle) == 0 {
|
|
235
|
+
t.Errorf("got empty compressed bundle")
|
|
236
|
+
}
|
|
237
|
+
compressedMsg := proto.Clone(msg).(*MsgInstallBundle)
|
|
238
|
+
err = msg.Compress()
|
|
239
|
+
if err != nil {
|
|
240
|
+
t.Fatal(err)
|
|
241
|
+
}
|
|
242
|
+
if !eq(msg, compressedMsg) {
|
|
243
|
+
t.Errorf("noop compress got %+v, want %+v", msg, compressedMsg)
|
|
244
|
+
}
|
|
245
|
+
err = msg.Uncompress()
|
|
246
|
+
if err != nil {
|
|
247
|
+
t.Fatal(err)
|
|
248
|
+
}
|
|
249
|
+
if !eq(msg, origMsg) {
|
|
250
|
+
t.Errorf("round-trip got %+v, want %+v", msg, origMsg)
|
|
251
|
+
}
|
|
252
|
+
msgModLo := proto.Clone(compressedMsg).(*MsgInstallBundle)
|
|
253
|
+
msgModLo.UncompressedSize--
|
|
254
|
+
err = msgModLo.Uncompress()
|
|
255
|
+
if err == nil {
|
|
256
|
+
t.Errorf("wanted Uncompress error for low uncompressed size")
|
|
257
|
+
}
|
|
258
|
+
msgModHi := proto.Clone(compressedMsg).(*MsgInstallBundle)
|
|
259
|
+
msgModHi.UncompressedSize++
|
|
260
|
+
err = msgModHi.Uncompress()
|
|
261
|
+
if err == nil {
|
|
262
|
+
t.Errorf("wanted Uncompress error for high uncompressed size")
|
|
263
|
+
}
|
|
264
|
+
}
|