@agoric/cosmos 0.34.2-dev-3573f79.0 → 0.34.2-dev-fed2b5e.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/app/app.go +41 -23
- package/git-revision.txt +1 -1
- package/package.json +2 -2
- package/proto/agoric/swingset/genesis.proto +10 -0
- package/types/kv_entry.go +114 -0
- package/types/kv_entry_helpers.go +234 -0
- package/types/kv_entry_helpers_test.go +237 -0
- package/types/kv_entry_test.go +143 -0
- package/x/swingset/genesis.go +30 -8
- package/x/swingset/keeper/extension_snapshotter.go +25 -37
- package/x/swingset/keeper/extension_snapshotter_test.go +0 -2
- package/x/swingset/keeper/keeper.go +14 -9
- package/x/swingset/keeper/keeper_test.go +77 -0
- package/x/swingset/keeper/querier.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler.go +23 -44
- package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
- package/x/swingset/swingset.go +71 -0
- package/x/swingset/types/genesis.pb.go +308 -18
- package/x/vstorage/keeper/grpc_query.go +1 -1
- package/x/vstorage/keeper/keeper.go +19 -19
- package/x/vstorage/keeper/keeper_grpc_test.go +3 -2
- package/x/vstorage/keeper/keeper_test.go +21 -20
- package/x/vstorage/keeper/querier.go +1 -1
- package/x/vstorage/types/types.go +0 -66
- package/x/vstorage/vstorage.go +19 -22
- package/x/vstorage/vstorage_test.go +14 -14
|
@@ -25,8 +25,9 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
|
|
25
25
|
|
|
26
26
|
// The initial or exported state.
|
|
27
27
|
type GenesisState struct {
|
|
28
|
-
Params
|
|
29
|
-
State
|
|
28
|
+
Params Params `protobuf:"bytes,2,opt,name=params,proto3" json:"params"`
|
|
29
|
+
State State `protobuf:"bytes,3,opt,name=state,proto3" json:"state"`
|
|
30
|
+
SwingStoreExportData []*SwingStoreExportDataEntry `protobuf:"bytes,4,rep,name=swing_store_export_data,json=swingStoreExportData,proto3" json:"swingStoreExportData"`
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
func (m *GenesisState) Reset() { *m = GenesisState{} }
|
|
@@ -76,29 +77,96 @@ func (m *GenesisState) GetState() State {
|
|
|
76
77
|
return State{}
|
|
77
78
|
}
|
|
78
79
|
|
|
80
|
+
func (m *GenesisState) GetSwingStoreExportData() []*SwingStoreExportDataEntry {
|
|
81
|
+
if m != nil {
|
|
82
|
+
return m.SwingStoreExportData
|
|
83
|
+
}
|
|
84
|
+
return nil
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// A SwingStore "export data" entry.
|
|
88
|
+
type SwingStoreExportDataEntry struct {
|
|
89
|
+
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
|
90
|
+
Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
func (m *SwingStoreExportDataEntry) Reset() { *m = SwingStoreExportDataEntry{} }
|
|
94
|
+
func (m *SwingStoreExportDataEntry) String() string { return proto.CompactTextString(m) }
|
|
95
|
+
func (*SwingStoreExportDataEntry) ProtoMessage() {}
|
|
96
|
+
func (*SwingStoreExportDataEntry) Descriptor() ([]byte, []int) {
|
|
97
|
+
return fileDescriptor_49b057311de9d296, []int{1}
|
|
98
|
+
}
|
|
99
|
+
func (m *SwingStoreExportDataEntry) XXX_Unmarshal(b []byte) error {
|
|
100
|
+
return m.Unmarshal(b)
|
|
101
|
+
}
|
|
102
|
+
func (m *SwingStoreExportDataEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
|
103
|
+
if deterministic {
|
|
104
|
+
return xxx_messageInfo_SwingStoreExportDataEntry.Marshal(b, m, deterministic)
|
|
105
|
+
} else {
|
|
106
|
+
b = b[:cap(b)]
|
|
107
|
+
n, err := m.MarshalToSizedBuffer(b)
|
|
108
|
+
if err != nil {
|
|
109
|
+
return nil, err
|
|
110
|
+
}
|
|
111
|
+
return b[:n], nil
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
func (m *SwingStoreExportDataEntry) XXX_Merge(src proto.Message) {
|
|
115
|
+
xxx_messageInfo_SwingStoreExportDataEntry.Merge(m, src)
|
|
116
|
+
}
|
|
117
|
+
func (m *SwingStoreExportDataEntry) XXX_Size() int {
|
|
118
|
+
return m.Size()
|
|
119
|
+
}
|
|
120
|
+
func (m *SwingStoreExportDataEntry) XXX_DiscardUnknown() {
|
|
121
|
+
xxx_messageInfo_SwingStoreExportDataEntry.DiscardUnknown(m)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var xxx_messageInfo_SwingStoreExportDataEntry proto.InternalMessageInfo
|
|
125
|
+
|
|
126
|
+
func (m *SwingStoreExportDataEntry) GetKey() string {
|
|
127
|
+
if m != nil {
|
|
128
|
+
return m.Key
|
|
129
|
+
}
|
|
130
|
+
return ""
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
func (m *SwingStoreExportDataEntry) GetValue() string {
|
|
134
|
+
if m != nil {
|
|
135
|
+
return m.Value
|
|
136
|
+
}
|
|
137
|
+
return ""
|
|
138
|
+
}
|
|
139
|
+
|
|
79
140
|
func init() {
|
|
80
141
|
proto.RegisterType((*GenesisState)(nil), "agoric.swingset.GenesisState")
|
|
142
|
+
proto.RegisterType((*SwingStoreExportDataEntry)(nil), "agoric.swingset.SwingStoreExportDataEntry")
|
|
81
143
|
}
|
|
82
144
|
|
|
83
145
|
func init() { proto.RegisterFile("agoric/swingset/genesis.proto", fileDescriptor_49b057311de9d296) }
|
|
84
146
|
|
|
85
147
|
var fileDescriptor_49b057311de9d296 = []byte{
|
|
86
|
-
//
|
|
87
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
148
|
+
// 334 bytes of a gzipped FileDescriptorProto
|
|
149
|
+
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x91, 0xcf, 0x4b, 0x02, 0x41,
|
|
150
|
+
0x1c, 0xc5, 0x77, 0xf2, 0x07, 0x38, 0x06, 0xc5, 0x22, 0xb9, 0x09, 0x8d, 0xe2, 0x49, 0x82, 0x76,
|
|
151
|
+
0xc0, 0xe8, 0x52, 0xa7, 0x2c, 0xe9, 0x1a, 0x2b, 0x5d, 0xba, 0xc8, 0xa8, 0xc3, 0xb4, 0xa8, 0x3b,
|
|
152
|
+
0xcb, 0x7c, 0xc7, 0x52, 0xfa, 0x27, 0xfa, 0x13, 0xfa, 0x73, 0x3c, 0x7a, 0xec, 0x24, 0xa1, 0x97,
|
|
153
|
+
0xe8, 0x6f, 0xe8, 0x10, 0x3b, 0xa3, 0x04, 0x6a, 0xb7, 0xb7, 0xfb, 0x79, 0xef, 0x0d, 0x33, 0x0f,
|
|
154
|
+
0x9f, 0x30, 0x21, 0x55, 0xd8, 0xa5, 0xf0, 0x12, 0x46, 0x02, 0xb8, 0xa6, 0x82, 0x47, 0x1c, 0x42,
|
|
155
|
+
0xf0, 0x63, 0x25, 0xb5, 0x74, 0x0f, 0x2c, 0xf6, 0xd7, 0xb8, 0x54, 0x10, 0x52, 0x48, 0xc3, 0x68,
|
|
156
|
+
0xa2, 0xac, 0xad, 0x44, 0x36, 0x5b, 0xd6, 0xc2, 0xf2, 0xea, 0x0f, 0xc2, 0xfb, 0x77, 0xb6, 0xb8,
|
|
157
|
+
0xa5, 0x99, 0xe6, 0xee, 0x05, 0xce, 0xc6, 0x4c, 0xb1, 0x21, 0x78, 0x7b, 0x15, 0x54, 0xcb, 0xd7,
|
|
158
|
+
0x8b, 0xfe, 0xc6, 0x41, 0xfe, 0xbd, 0xc1, 0x8d, 0xf4, 0x74, 0x5e, 0x76, 0x82, 0x95, 0xd9, 0xad,
|
|
159
|
+
0xe3, 0x0c, 0x24, 0x79, 0x2f, 0x65, 0x52, 0x47, 0x5b, 0x29, 0xd3, 0xbe, 0x0a, 0x59, 0xab, 0xfb,
|
|
160
|
+
0x8a, 0x8b, 0x06, 0xb7, 0x41, 0x4b, 0xc5, 0xdb, 0x7c, 0x1c, 0x4b, 0xa5, 0xdb, 0x3d, 0xa6, 0x99,
|
|
161
|
+
0x97, 0xae, 0xa4, 0x6a, 0xf9, 0xfa, 0xe9, 0x76, 0x4b, 0x22, 0x5a, 0x89, 0xbd, 0x69, 0xdc, 0xb7,
|
|
162
|
+
0x4c, 0xb3, 0x66, 0xa4, 0xd5, 0xa4, 0xe1, 0x7d, 0xcf, 0xcb, 0x05, 0xd8, 0x81, 0x83, 0x9d, 0x7f,
|
|
163
|
+
0x2f, 0xd3, 0x5f, 0xef, 0x65, 0xa7, 0x7a, 0x83, 0x8f, 0xff, 0xad, 0x74, 0x0f, 0x71, 0xaa, 0xcf,
|
|
164
|
+
0x27, 0x1e, 0xaa, 0xa0, 0x5a, 0x2e, 0x48, 0xa4, 0x5b, 0xc0, 0x99, 0x67, 0x36, 0x18, 0x71, 0xf3,
|
|
165
|
+
0x36, 0xb9, 0xc0, 0x7e, 0x34, 0x1e, 0xa6, 0x0b, 0x82, 0x66, 0x0b, 0x82, 0x3e, 0x17, 0x04, 0xbd,
|
|
166
|
+
0x2d, 0x89, 0x33, 0x5b, 0x12, 0xe7, 0x63, 0x49, 0x9c, 0xc7, 0x2b, 0x11, 0xea, 0xa7, 0x51, 0xc7,
|
|
167
|
+
0xef, 0xca, 0x21, 0xbd, 0xb6, 0x43, 0xd8, 0x1b, 0x9d, 0x41, 0xaf, 0x4f, 0x85, 0x1c, 0xb0, 0x48,
|
|
168
|
+
0xd0, 0xae, 0x84, 0xa1, 0x04, 0x3a, 0xfe, 0xdb, 0x48, 0x4f, 0x62, 0x0e, 0x9d, 0xac, 0x59, 0xe8,
|
|
169
|
+
0xfc, 0x37, 0x00, 0x00, 0xff, 0xff, 0x94, 0xe9, 0x22, 0x36, 0x09, 0x02, 0x00, 0x00,
|
|
102
170
|
}
|
|
103
171
|
|
|
104
172
|
func (m *GenesisState) Marshal() (dAtA []byte, err error) {
|
|
@@ -121,6 +189,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
|
121
189
|
_ = i
|
|
122
190
|
var l int
|
|
123
191
|
_ = l
|
|
192
|
+
if len(m.SwingStoreExportData) > 0 {
|
|
193
|
+
for iNdEx := len(m.SwingStoreExportData) - 1; iNdEx >= 0; iNdEx-- {
|
|
194
|
+
{
|
|
195
|
+
size, err := m.SwingStoreExportData[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
|
196
|
+
if err != nil {
|
|
197
|
+
return 0, err
|
|
198
|
+
}
|
|
199
|
+
i -= size
|
|
200
|
+
i = encodeVarintGenesis(dAtA, i, uint64(size))
|
|
201
|
+
}
|
|
202
|
+
i--
|
|
203
|
+
dAtA[i] = 0x22
|
|
204
|
+
}
|
|
205
|
+
}
|
|
124
206
|
{
|
|
125
207
|
size, err := m.State.MarshalToSizedBuffer(dAtA[:i])
|
|
126
208
|
if err != nil {
|
|
@@ -144,6 +226,43 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
|
144
226
|
return len(dAtA) - i, nil
|
|
145
227
|
}
|
|
146
228
|
|
|
229
|
+
func (m *SwingStoreExportDataEntry) Marshal() (dAtA []byte, err error) {
|
|
230
|
+
size := m.Size()
|
|
231
|
+
dAtA = make([]byte, size)
|
|
232
|
+
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
|
233
|
+
if err != nil {
|
|
234
|
+
return nil, err
|
|
235
|
+
}
|
|
236
|
+
return dAtA[:n], nil
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
func (m *SwingStoreExportDataEntry) MarshalTo(dAtA []byte) (int, error) {
|
|
240
|
+
size := m.Size()
|
|
241
|
+
return m.MarshalToSizedBuffer(dAtA[:size])
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
func (m *SwingStoreExportDataEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|
245
|
+
i := len(dAtA)
|
|
246
|
+
_ = i
|
|
247
|
+
var l int
|
|
248
|
+
_ = l
|
|
249
|
+
if len(m.Value) > 0 {
|
|
250
|
+
i -= len(m.Value)
|
|
251
|
+
copy(dAtA[i:], m.Value)
|
|
252
|
+
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Value)))
|
|
253
|
+
i--
|
|
254
|
+
dAtA[i] = 0x12
|
|
255
|
+
}
|
|
256
|
+
if len(m.Key) > 0 {
|
|
257
|
+
i -= len(m.Key)
|
|
258
|
+
copy(dAtA[i:], m.Key)
|
|
259
|
+
i = encodeVarintGenesis(dAtA, i, uint64(len(m.Key)))
|
|
260
|
+
i--
|
|
261
|
+
dAtA[i] = 0xa
|
|
262
|
+
}
|
|
263
|
+
return len(dAtA) - i, nil
|
|
264
|
+
}
|
|
265
|
+
|
|
147
266
|
func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int {
|
|
148
267
|
offset -= sovGenesis(v)
|
|
149
268
|
base := offset
|
|
@@ -165,6 +284,29 @@ func (m *GenesisState) Size() (n int) {
|
|
|
165
284
|
n += 1 + l + sovGenesis(uint64(l))
|
|
166
285
|
l = m.State.Size()
|
|
167
286
|
n += 1 + l + sovGenesis(uint64(l))
|
|
287
|
+
if len(m.SwingStoreExportData) > 0 {
|
|
288
|
+
for _, e := range m.SwingStoreExportData {
|
|
289
|
+
l = e.Size()
|
|
290
|
+
n += 1 + l + sovGenesis(uint64(l))
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return n
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
func (m *SwingStoreExportDataEntry) Size() (n int) {
|
|
297
|
+
if m == nil {
|
|
298
|
+
return 0
|
|
299
|
+
}
|
|
300
|
+
var l int
|
|
301
|
+
_ = l
|
|
302
|
+
l = len(m.Key)
|
|
303
|
+
if l > 0 {
|
|
304
|
+
n += 1 + l + sovGenesis(uint64(l))
|
|
305
|
+
}
|
|
306
|
+
l = len(m.Value)
|
|
307
|
+
if l > 0 {
|
|
308
|
+
n += 1 + l + sovGenesis(uint64(l))
|
|
309
|
+
}
|
|
168
310
|
return n
|
|
169
311
|
}
|
|
170
312
|
|
|
@@ -269,6 +411,154 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error {
|
|
|
269
411
|
return err
|
|
270
412
|
}
|
|
271
413
|
iNdEx = postIndex
|
|
414
|
+
case 4:
|
|
415
|
+
if wireType != 2 {
|
|
416
|
+
return fmt.Errorf("proto: wrong wireType = %d for field SwingStoreExportData", wireType)
|
|
417
|
+
}
|
|
418
|
+
var msglen int
|
|
419
|
+
for shift := uint(0); ; shift += 7 {
|
|
420
|
+
if shift >= 64 {
|
|
421
|
+
return ErrIntOverflowGenesis
|
|
422
|
+
}
|
|
423
|
+
if iNdEx >= l {
|
|
424
|
+
return io.ErrUnexpectedEOF
|
|
425
|
+
}
|
|
426
|
+
b := dAtA[iNdEx]
|
|
427
|
+
iNdEx++
|
|
428
|
+
msglen |= int(b&0x7F) << shift
|
|
429
|
+
if b < 0x80 {
|
|
430
|
+
break
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if msglen < 0 {
|
|
434
|
+
return ErrInvalidLengthGenesis
|
|
435
|
+
}
|
|
436
|
+
postIndex := iNdEx + msglen
|
|
437
|
+
if postIndex < 0 {
|
|
438
|
+
return ErrInvalidLengthGenesis
|
|
439
|
+
}
|
|
440
|
+
if postIndex > l {
|
|
441
|
+
return io.ErrUnexpectedEOF
|
|
442
|
+
}
|
|
443
|
+
m.SwingStoreExportData = append(m.SwingStoreExportData, &SwingStoreExportDataEntry{})
|
|
444
|
+
if err := m.SwingStoreExportData[len(m.SwingStoreExportData)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
|
445
|
+
return err
|
|
446
|
+
}
|
|
447
|
+
iNdEx = postIndex
|
|
448
|
+
default:
|
|
449
|
+
iNdEx = preIndex
|
|
450
|
+
skippy, err := skipGenesis(dAtA[iNdEx:])
|
|
451
|
+
if err != nil {
|
|
452
|
+
return err
|
|
453
|
+
}
|
|
454
|
+
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
455
|
+
return ErrInvalidLengthGenesis
|
|
456
|
+
}
|
|
457
|
+
if (iNdEx + skippy) > l {
|
|
458
|
+
return io.ErrUnexpectedEOF
|
|
459
|
+
}
|
|
460
|
+
iNdEx += skippy
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
if iNdEx > l {
|
|
465
|
+
return io.ErrUnexpectedEOF
|
|
466
|
+
}
|
|
467
|
+
return nil
|
|
468
|
+
}
|
|
469
|
+
func (m *SwingStoreExportDataEntry) Unmarshal(dAtA []byte) error {
|
|
470
|
+
l := len(dAtA)
|
|
471
|
+
iNdEx := 0
|
|
472
|
+
for iNdEx < l {
|
|
473
|
+
preIndex := iNdEx
|
|
474
|
+
var wire uint64
|
|
475
|
+
for shift := uint(0); ; shift += 7 {
|
|
476
|
+
if shift >= 64 {
|
|
477
|
+
return ErrIntOverflowGenesis
|
|
478
|
+
}
|
|
479
|
+
if iNdEx >= l {
|
|
480
|
+
return io.ErrUnexpectedEOF
|
|
481
|
+
}
|
|
482
|
+
b := dAtA[iNdEx]
|
|
483
|
+
iNdEx++
|
|
484
|
+
wire |= uint64(b&0x7F) << shift
|
|
485
|
+
if b < 0x80 {
|
|
486
|
+
break
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
fieldNum := int32(wire >> 3)
|
|
490
|
+
wireType := int(wire & 0x7)
|
|
491
|
+
if wireType == 4 {
|
|
492
|
+
return fmt.Errorf("proto: SwingStoreExportDataEntry: wiretype end group for non-group")
|
|
493
|
+
}
|
|
494
|
+
if fieldNum <= 0 {
|
|
495
|
+
return fmt.Errorf("proto: SwingStoreExportDataEntry: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
496
|
+
}
|
|
497
|
+
switch fieldNum {
|
|
498
|
+
case 1:
|
|
499
|
+
if wireType != 2 {
|
|
500
|
+
return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType)
|
|
501
|
+
}
|
|
502
|
+
var stringLen uint64
|
|
503
|
+
for shift := uint(0); ; shift += 7 {
|
|
504
|
+
if shift >= 64 {
|
|
505
|
+
return ErrIntOverflowGenesis
|
|
506
|
+
}
|
|
507
|
+
if iNdEx >= l {
|
|
508
|
+
return io.ErrUnexpectedEOF
|
|
509
|
+
}
|
|
510
|
+
b := dAtA[iNdEx]
|
|
511
|
+
iNdEx++
|
|
512
|
+
stringLen |= uint64(b&0x7F) << shift
|
|
513
|
+
if b < 0x80 {
|
|
514
|
+
break
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
intStringLen := int(stringLen)
|
|
518
|
+
if intStringLen < 0 {
|
|
519
|
+
return ErrInvalidLengthGenesis
|
|
520
|
+
}
|
|
521
|
+
postIndex := iNdEx + intStringLen
|
|
522
|
+
if postIndex < 0 {
|
|
523
|
+
return ErrInvalidLengthGenesis
|
|
524
|
+
}
|
|
525
|
+
if postIndex > l {
|
|
526
|
+
return io.ErrUnexpectedEOF
|
|
527
|
+
}
|
|
528
|
+
m.Key = string(dAtA[iNdEx:postIndex])
|
|
529
|
+
iNdEx = postIndex
|
|
530
|
+
case 2:
|
|
531
|
+
if wireType != 2 {
|
|
532
|
+
return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType)
|
|
533
|
+
}
|
|
534
|
+
var stringLen uint64
|
|
535
|
+
for shift := uint(0); ; shift += 7 {
|
|
536
|
+
if shift >= 64 {
|
|
537
|
+
return ErrIntOverflowGenesis
|
|
538
|
+
}
|
|
539
|
+
if iNdEx >= l {
|
|
540
|
+
return io.ErrUnexpectedEOF
|
|
541
|
+
}
|
|
542
|
+
b := dAtA[iNdEx]
|
|
543
|
+
iNdEx++
|
|
544
|
+
stringLen |= uint64(b&0x7F) << shift
|
|
545
|
+
if b < 0x80 {
|
|
546
|
+
break
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
intStringLen := int(stringLen)
|
|
550
|
+
if intStringLen < 0 {
|
|
551
|
+
return ErrInvalidLengthGenesis
|
|
552
|
+
}
|
|
553
|
+
postIndex := iNdEx + intStringLen
|
|
554
|
+
if postIndex < 0 {
|
|
555
|
+
return ErrInvalidLengthGenesis
|
|
556
|
+
}
|
|
557
|
+
if postIndex > l {
|
|
558
|
+
return io.ErrUnexpectedEOF
|
|
559
|
+
}
|
|
560
|
+
m.Value = string(dAtA[iNdEx:postIndex])
|
|
561
|
+
iNdEx = postIndex
|
|
272
562
|
default:
|
|
273
563
|
iNdEx = preIndex
|
|
274
564
|
skippy, err := skipGenesis(dAtA[iNdEx:])
|
|
@@ -200,7 +200,7 @@ func (k Querier) CapData(c context.Context, req *types.QueryCapDataRequest) (*ty
|
|
|
200
200
|
|
|
201
201
|
// Read data, auto-upgrading a standalone value to a single-value StreamCell.
|
|
202
202
|
entry := k.GetEntry(ctx, req.Path)
|
|
203
|
-
if !entry.
|
|
203
|
+
if !entry.HasValue() {
|
|
204
204
|
return nil, status.Error(codes.FailedPrecondition, "no data")
|
|
205
205
|
}
|
|
206
206
|
value := entry.StringValue()
|
|
@@ -35,7 +35,7 @@ type ProposedChange struct {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
type ChangeManager interface {
|
|
38
|
-
Track(ctx sdk.Context, k Keeper, entry
|
|
38
|
+
Track(ctx sdk.Context, k Keeper, entry agoric.KVEntry, isLegacy bool)
|
|
39
39
|
EmitEvents(ctx sdk.Context, k Keeper)
|
|
40
40
|
Rollback(ctx sdk.Context)
|
|
41
41
|
}
|
|
@@ -65,8 +65,8 @@ type Keeper struct {
|
|
|
65
65
|
storeKey sdk.StoreKey
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
func (bcm *BatchingChangeManager) Track(ctx sdk.Context, k Keeper, entry
|
|
69
|
-
path := entry.
|
|
68
|
+
func (bcm *BatchingChangeManager) Track(ctx sdk.Context, k Keeper, entry agoric.KVEntry, isLegacy bool) {
|
|
69
|
+
path := entry.Key()
|
|
70
70
|
// TODO: differentiate between deletion and setting empty string?
|
|
71
71
|
// Using empty string for deletion for backwards compatibility
|
|
72
72
|
value := entry.StringValue()
|
|
@@ -177,7 +177,7 @@ func (k Keeper) ImportStorage(ctx sdk.Context, entries []*types.DataEntry) {
|
|
|
177
177
|
for _, entry := range entries {
|
|
178
178
|
// This set does the bookkeeping for us in case the entries aren't a
|
|
179
179
|
// complete tree.
|
|
180
|
-
k.SetStorage(ctx,
|
|
180
|
+
k.SetStorage(ctx, agoric.NewKVEntry(entry.Path, entry.Value))
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
|
|
@@ -205,22 +205,22 @@ func (k Keeper) EmitChange(ctx sdk.Context, change *ProposedChange) {
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
// GetEntry gets generic storage. The default value is an empty string.
|
|
208
|
-
func (k Keeper) GetEntry(ctx sdk.Context, path string)
|
|
208
|
+
func (k Keeper) GetEntry(ctx sdk.Context, path string) agoric.KVEntry {
|
|
209
209
|
//fmt.Printf("GetEntry(%s)\n", path);
|
|
210
210
|
store := ctx.KVStore(k.storeKey)
|
|
211
211
|
encodedKey := types.PathToEncodedKey(path)
|
|
212
212
|
rawValue := store.Get(encodedKey)
|
|
213
213
|
if len(rawValue) == 0 {
|
|
214
|
-
return
|
|
214
|
+
return agoric.NewKVEntryWithNoValue(path)
|
|
215
215
|
}
|
|
216
216
|
if bytes.Equal(rawValue, types.EncodedNoDataValue) {
|
|
217
|
-
return
|
|
217
|
+
return agoric.NewKVEntryWithNoValue(path)
|
|
218
218
|
}
|
|
219
219
|
value, hasPrefix := cutPrefix(rawValue, types.EncodedDataPrefix)
|
|
220
220
|
if !hasPrefix {
|
|
221
221
|
panic(fmt.Errorf("value at path %q starts with unexpected prefix", path))
|
|
222
222
|
}
|
|
223
|
-
return
|
|
223
|
+
return agoric.NewKVEntry(path, string(value))
|
|
224
224
|
}
|
|
225
225
|
|
|
226
226
|
func (k Keeper) getKeyIterator(ctx sdk.Context, path string) db.Iterator {
|
|
@@ -249,7 +249,7 @@ func (k Keeper) GetChildren(ctx sdk.Context, path string) *types.Children {
|
|
|
249
249
|
// (just an empty string) and exist only to provide linkage to subnodes with
|
|
250
250
|
// data.
|
|
251
251
|
func (k Keeper) HasStorage(ctx sdk.Context, path string) bool {
|
|
252
|
-
return k.GetEntry(ctx, path).
|
|
252
|
+
return k.GetEntry(ctx, path).HasValue()
|
|
253
253
|
}
|
|
254
254
|
|
|
255
255
|
// HasEntry tells if a given path has either subnodes or data.
|
|
@@ -278,12 +278,12 @@ func (k Keeper) FlushChangeEvents(ctx sdk.Context) {
|
|
|
278
278
|
k.changeManager.Rollback(ctx)
|
|
279
279
|
}
|
|
280
280
|
|
|
281
|
-
func (k Keeper) SetStorageAndNotify(ctx sdk.Context, entry
|
|
281
|
+
func (k Keeper) SetStorageAndNotify(ctx sdk.Context, entry agoric.KVEntry) {
|
|
282
282
|
k.changeManager.Track(ctx, k, entry, false)
|
|
283
283
|
k.SetStorage(ctx, entry)
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
func (k Keeper) LegacySetStorageAndNotify(ctx sdk.Context, entry
|
|
286
|
+
func (k Keeper) LegacySetStorageAndNotify(ctx sdk.Context, entry agoric.KVEntry) {
|
|
287
287
|
k.changeManager.Track(ctx, k, entry, true)
|
|
288
288
|
k.SetStorage(ctx, entry)
|
|
289
289
|
}
|
|
@@ -308,7 +308,7 @@ func (k Keeper) AppendStorageValueAndNotify(ctx sdk.Context, path, value string)
|
|
|
308
308
|
if err != nil {
|
|
309
309
|
return err
|
|
310
310
|
}
|
|
311
|
-
k.SetStorageAndNotify(ctx,
|
|
311
|
+
k.SetStorageAndNotify(ctx, agoric.NewKVEntry(path, string(bz)))
|
|
312
312
|
return nil
|
|
313
313
|
}
|
|
314
314
|
|
|
@@ -320,12 +320,12 @@ func componentsToPath(components []string) string {
|
|
|
320
320
|
//
|
|
321
321
|
// Maintains the invariant: path entries exist if and only if self or some
|
|
322
322
|
// descendant has non-empty storage
|
|
323
|
-
func (k Keeper) SetStorage(ctx sdk.Context, entry
|
|
323
|
+
func (k Keeper) SetStorage(ctx sdk.Context, entry agoric.KVEntry) {
|
|
324
324
|
store := ctx.KVStore(k.storeKey)
|
|
325
|
-
path := entry.
|
|
325
|
+
path := entry.Key()
|
|
326
326
|
encodedKey := types.PathToEncodedKey(path)
|
|
327
327
|
|
|
328
|
-
if !entry.
|
|
328
|
+
if !entry.HasValue() {
|
|
329
329
|
if !k.HasChildren(ctx, path) {
|
|
330
330
|
// We have no children, can delete.
|
|
331
331
|
store.Delete(encodedKey)
|
|
@@ -340,7 +340,7 @@ func (k Keeper) SetStorage(ctx sdk.Context, entry types.StorageEntry) {
|
|
|
340
340
|
|
|
341
341
|
// Update our other parent children.
|
|
342
342
|
pathComponents := strings.Split(path, types.PathSeparator)
|
|
343
|
-
if !entry.
|
|
343
|
+
if !entry.HasValue() {
|
|
344
344
|
// delete placeholder ancestors if they're no longer needed
|
|
345
345
|
for i := len(pathComponents) - 1; i >= 0; i-- {
|
|
346
346
|
ancestor := componentsToPath(pathComponents[0:i])
|
|
@@ -381,7 +381,7 @@ func (k Keeper) GetNoDataValue() []byte {
|
|
|
381
381
|
|
|
382
382
|
func (k Keeper) getIntValue(ctx sdk.Context, path string) (sdk.Int, error) {
|
|
383
383
|
indexEntry := k.GetEntry(ctx, path)
|
|
384
|
-
if !indexEntry.
|
|
384
|
+
if !indexEntry.HasValue() {
|
|
385
385
|
return sdk.NewInt(0), nil
|
|
386
386
|
}
|
|
387
387
|
|
|
@@ -420,10 +420,10 @@ func (k Keeper) PushQueueItem(ctx sdk.Context, queuePath string, value string) e
|
|
|
420
420
|
|
|
421
421
|
// Set the vstorage corresponding to the queue entry for the current tail.
|
|
422
422
|
path := queuePath + "." + tail.String()
|
|
423
|
-
k.SetStorage(ctx,
|
|
423
|
+
k.SetStorage(ctx, agoric.NewKVEntry(path, value))
|
|
424
424
|
|
|
425
425
|
// Update the tail to point to the next available entry.
|
|
426
426
|
path = queuePath + ".tail"
|
|
427
|
-
k.SetStorage(ctx,
|
|
427
|
+
k.SetStorage(ctx, agoric.NewKVEntry(path, nextTail.String()))
|
|
428
428
|
return nil
|
|
429
429
|
}
|
|
@@ -9,6 +9,7 @@ import (
|
|
|
9
9
|
grpcCodes "google.golang.org/grpc/codes"
|
|
10
10
|
grpcStatus "google.golang.org/grpc/status"
|
|
11
11
|
|
|
12
|
+
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
12
13
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/capdata"
|
|
13
14
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
14
15
|
|
|
@@ -271,9 +272,9 @@ func TestCapData(t *testing.T) {
|
|
|
271
272
|
for _, desc := range testCases {
|
|
272
273
|
desc.request.Path = "key"
|
|
273
274
|
if desc.data == nil {
|
|
274
|
-
keeper.SetStorage(ctx,
|
|
275
|
+
keeper.SetStorage(ctx, agoric.NewKVEntryWithNoValue(desc.request.Path))
|
|
275
276
|
} else {
|
|
276
|
-
keeper.SetStorage(ctx,
|
|
277
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry(desc.request.Path, *desc.data))
|
|
277
278
|
}
|
|
278
279
|
resp, err := querier.CapData(sdk.WrapSDKContext(ctx), &desc.request)
|
|
279
280
|
if desc.errCode == grpcCodes.OK {
|
|
@@ -4,6 +4,7 @@ import (
|
|
|
4
4
|
"reflect"
|
|
5
5
|
"testing"
|
|
6
6
|
|
|
7
|
+
agoric "github.com/Agoric/agoric-sdk/golang/cosmos/types"
|
|
7
8
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types"
|
|
8
9
|
|
|
9
10
|
"github.com/cosmos/cosmos-sdk/store"
|
|
@@ -57,19 +58,19 @@ func TestStorage(t *testing.T) {
|
|
|
57
58
|
ctx, keeper := testKit.ctx, testKit.vstorageKeeper
|
|
58
59
|
|
|
59
60
|
// Test that we can store and retrieve a value.
|
|
60
|
-
keeper.SetStorage(ctx,
|
|
61
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("inited", "initValue"))
|
|
61
62
|
if got := keeper.GetEntry(ctx, "inited").StringValue(); got != "initValue" {
|
|
62
63
|
t.Errorf("got %q, want %q", got, "initValue")
|
|
63
64
|
}
|
|
64
65
|
|
|
65
66
|
// Test that unknown children return empty string.
|
|
66
|
-
if got := keeper.GetEntry(ctx, "unknown"); got.
|
|
67
|
+
if got := keeper.GetEntry(ctx, "unknown"); got.HasValue() || got.StringValue() != "" {
|
|
67
68
|
t.Errorf("got %q, want no value", got.StringValue())
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
// Test that we can store and retrieve an empty string value.
|
|
71
|
-
keeper.SetStorage(ctx,
|
|
72
|
-
if got := keeper.GetEntry(ctx, "inited"); !got.
|
|
72
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("inited", ""))
|
|
73
|
+
if got := keeper.GetEntry(ctx, "inited"); !got.HasValue() || got.StringValue() != "" {
|
|
73
74
|
t.Errorf("got %q, want empty string", got.StringValue())
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -78,18 +79,18 @@ func TestStorage(t *testing.T) {
|
|
|
78
79
|
t.Errorf("got %q children, want [inited]", got.Children)
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
keeper.SetStorage(ctx,
|
|
82
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("key1", "value1"))
|
|
82
83
|
if got := keeper.GetChildren(ctx, ""); !childrenEqual(got.Children, []string{"inited", "key1"}) {
|
|
83
84
|
t.Errorf("got %q children, want [inited,key1]", got.Children)
|
|
84
85
|
}
|
|
85
86
|
|
|
86
87
|
// Check alphabetical.
|
|
87
|
-
keeper.SetStorage(ctx,
|
|
88
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("alpha2", "value2"))
|
|
88
89
|
if got := keeper.GetChildren(ctx, ""); !childrenEqual(got.Children, []string{"alpha2", "inited", "key1"}) {
|
|
89
90
|
t.Errorf("got %q children, want [alpha2,inited,key1]", got.Children)
|
|
90
91
|
}
|
|
91
92
|
|
|
92
|
-
keeper.SetStorage(ctx,
|
|
93
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("beta3", "value3"))
|
|
93
94
|
if got := keeper.GetChildren(ctx, ""); !childrenEqual(got.Children, []string{"alpha2", "beta3", "inited", "key1"}) {
|
|
94
95
|
t.Errorf("got %q children, want [alpha2,beta3,inited,key1]", got.Children)
|
|
95
96
|
}
|
|
@@ -99,7 +100,7 @@ func TestStorage(t *testing.T) {
|
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
// Check adding children.
|
|
102
|
-
keeper.SetStorage(ctx,
|
|
103
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("key1.child1", "value1child"))
|
|
103
104
|
if got := keeper.GetEntry(ctx, "key1.child1").StringValue(); got != "value1child" {
|
|
104
105
|
t.Errorf("got %q, want %q", got, "value1child")
|
|
105
106
|
}
|
|
@@ -109,7 +110,7 @@ func TestStorage(t *testing.T) {
|
|
|
109
110
|
}
|
|
110
111
|
|
|
111
112
|
// Add a grandchild.
|
|
112
|
-
keeper.SetStorage(ctx,
|
|
113
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("key1.child1.grandchild1", "value1grandchild"))
|
|
113
114
|
if got := keeper.GetEntry(ctx, "key1.child1.grandchild1").StringValue(); got != "value1grandchild" {
|
|
114
115
|
t.Errorf("got %q, want %q", got, "value1grandchild")
|
|
115
116
|
}
|
|
@@ -119,7 +120,7 @@ func TestStorage(t *testing.T) {
|
|
|
119
120
|
}
|
|
120
121
|
|
|
121
122
|
// Delete the child's contents.
|
|
122
|
-
keeper.SetStorage(ctx,
|
|
123
|
+
keeper.SetStorage(ctx, agoric.NewKVEntryWithNoValue("key1.child1"))
|
|
123
124
|
if got := keeper.GetChildren(ctx, "key1"); !childrenEqual(got.Children, []string{"child1"}) {
|
|
124
125
|
t.Errorf("got %q children, want [child1]", got.Children)
|
|
125
126
|
}
|
|
@@ -129,7 +130,7 @@ func TestStorage(t *testing.T) {
|
|
|
129
130
|
}
|
|
130
131
|
|
|
131
132
|
// Delete the grandchild's contents.
|
|
132
|
-
keeper.SetStorage(ctx,
|
|
133
|
+
keeper.SetStorage(ctx, agoric.NewKVEntryWithNoValue("key1.child1.grandchild1"))
|
|
133
134
|
if got := keeper.GetChildren(ctx, "key1.child1"); !childrenEqual(got.Children, []string{}) {
|
|
134
135
|
t.Errorf("got %q children, want []", got.Children)
|
|
135
136
|
}
|
|
@@ -139,13 +140,13 @@ func TestStorage(t *testing.T) {
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
// See about deleting the parent.
|
|
142
|
-
keeper.SetStorage(ctx,
|
|
143
|
+
keeper.SetStorage(ctx, agoric.NewKVEntryWithNoValue("key1"))
|
|
143
144
|
if got := keeper.GetChildren(ctx, ""); !childrenEqual(got.Children, []string{"alpha2", "beta3", "inited"}) {
|
|
144
145
|
t.Errorf("got %q children, want [alpha2,beta3,inited]", got.Children)
|
|
145
146
|
}
|
|
146
147
|
|
|
147
148
|
// Do a deep set.
|
|
148
|
-
keeper.SetStorage(ctx,
|
|
149
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("key2.child2.grandchild2", "value2grandchild"))
|
|
149
150
|
if got := keeper.GetChildren(ctx, ""); !childrenEqual(got.Children, []string{"alpha2", "beta3", "inited", "key2"}) {
|
|
150
151
|
t.Errorf("got %q children, want [alpha2,beta3,inited,key2]", got.Children)
|
|
151
152
|
}
|
|
@@ -157,7 +158,7 @@ func TestStorage(t *testing.T) {
|
|
|
157
158
|
}
|
|
158
159
|
|
|
159
160
|
// Do another deep set.
|
|
160
|
-
keeper.SetStorage(ctx,
|
|
161
|
+
keeper.SetStorage(ctx, agoric.NewKVEntry("key2.child2.grandchild2a", "value2grandchilda"))
|
|
161
162
|
if got := keeper.GetChildren(ctx, "key2.child2"); !childrenEqual(got.Children, []string{"grandchild2", "grandchild2a"}) {
|
|
162
163
|
t.Errorf("got %q children, want [grandchild2,grandchild2a]", got.Children)
|
|
163
164
|
}
|
|
@@ -191,12 +192,12 @@ func TestStorageNotify(t *testing.T) {
|
|
|
191
192
|
tk := makeTestKit()
|
|
192
193
|
ctx, keeper := tk.ctx, tk.vstorageKeeper
|
|
193
194
|
|
|
194
|
-
keeper.SetStorageAndNotify(ctx,
|
|
195
|
-
keeper.LegacySetStorageAndNotify(ctx,
|
|
196
|
-
keeper.SetStorageAndNotify(ctx,
|
|
197
|
-
keeper.SetStorageAndNotify(ctx,
|
|
198
|
-
keeper.LegacySetStorageAndNotify(ctx,
|
|
199
|
-
keeper.SetStorageAndNotify(ctx,
|
|
195
|
+
keeper.SetStorageAndNotify(ctx, agoric.NewKVEntry("notify.noLegacy", "noLegacyValue"))
|
|
196
|
+
keeper.LegacySetStorageAndNotify(ctx, agoric.NewKVEntry("notify.legacy", "legacyValue"))
|
|
197
|
+
keeper.SetStorageAndNotify(ctx, agoric.NewKVEntry("notify.noLegacy2", "noLegacyValue2"))
|
|
198
|
+
keeper.SetStorageAndNotify(ctx, agoric.NewKVEntry("notify.legacy2", "legacyValue2"))
|
|
199
|
+
keeper.LegacySetStorageAndNotify(ctx, agoric.NewKVEntry("notify.legacy2", "legacyValue2b"))
|
|
200
|
+
keeper.SetStorageAndNotify(ctx, agoric.NewKVEntry("notify.noLegacy2", "noLegacyValue2b"))
|
|
200
201
|
|
|
201
202
|
// Check the batched events.
|
|
202
203
|
expectedBeforeFlushEvents := sdk.Events{}
|