@agoric/cosmos 0.35.0-u21.0 → 0.35.0-u22.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 +11 -187
- package/Makefile +2 -2
- package/ante/ante.go +2 -2
- package/ante/inbound.go +1 -2
- package/ante/inbound_test.go +3 -1
- package/ante/vm_admission.go +1 -2
- package/app/app.go +255 -174
- package/app/encoding.go +6 -3
- package/app/export.go +50 -21
- package/app/genesis.go +7 -5
- package/app/params/encoding.go +1 -1
- package/app/params/proto.go +6 -4
- package/app/sim_test.go +11 -13
- package/app/txconfig/tx_config.go +169 -0
- package/app/upgrade.go +52 -97
- package/app/upgrade_test.go +1 -1
- package/cmd/agd/agvm.go +1 -1
- package/cmd/agd/main.go +1 -1
- package/cmd/libdaemon/main.go +2 -2
- package/daemon/cmd/root.go +99 -30
- package/daemon/cmd/root_test.go +12 -27
- package/daemon/main.go +2 -9
- package/git-revision.txt +1 -1
- package/go.mod +129 -109
- package/go.sum +228 -469
- package/package.json +2 -2
- package/proto/agoric/swingset/msgs.proto +46 -9
- package/proto/agoric/swingset/swingset.proto +7 -2
- package/proto/agoric/vbank/vbank.proto +1 -1
- package/proto/agoric/vibc/msgs.proto +4 -0
- package/tests/e2e/vbank/vbank_test.go +172 -0
- package/tests/integrations/types/aminojson_test.go +214 -0
- package/tests/integrations/vbank/vbank_test.go +348 -0
- package/third_party/proto/amino/amino.proto +6 -1
- package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
- package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
- package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
- package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
- package/types/address_hooks.go +2 -2
- package/types/address_hooks_test.go +3 -3
- package/types/ibc_packet.go +3 -3
- package/types/ibc_packet_test.go +3 -3
- package/types/kv_entry_helpers.go +3 -3
- package/types/kv_entry_helpers_test.go +2 -2
- package/types/legacy_address_encoder.go +58 -0
- package/vm/proto_json_test.go +1 -1
- package/vm/server.go +2 -1
- package/x/swingset/abci.go +2 -2
- package/x/swingset/client/cli/tx.go +16 -14
- package/x/swingset/config.go +1 -1
- package/x/swingset/genesis.go +2 -1
- package/x/swingset/handler.go +2 -1
- package/x/swingset/keeper/extension_snapshotter.go +14 -5
- package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
- package/x/swingset/keeper/keeper.go +21 -17
- package/x/swingset/keeper/keeper_test.go +10 -7
- package/x/swingset/keeper/msg_server.go +26 -5
- package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
- package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
- package/x/swingset/module.go +20 -22
- package/x/swingset/types/codec.go +10 -5
- package/x/swingset/types/default-params.go +13 -12
- package/x/swingset/types/expected_keepers.go +5 -4
- package/x/swingset/types/msgs.go +50 -36
- package/x/swingset/types/msgs.pb.go +60 -51
- package/x/swingset/types/params_test.go +21 -20
- package/x/swingset/types/swingset.pb.go +67 -61
- package/x/vbank/genesis.go +12 -8
- package/x/vbank/handler.go +2 -1
- package/x/vbank/keeper/grpc_query.go +4 -1
- package/x/vbank/keeper/keeper.go +108 -23
- package/x/vbank/keeper/querier.go +4 -1
- package/x/vbank/keeper/rewards.go +6 -2
- package/x/vbank/module.go +47 -75
- package/x/vbank/types/expected_keepers.go +15 -10
- package/x/vbank/types/key.go +3 -0
- package/x/vbank/types/params.go +4 -3
- package/x/vbank/types/vbank.pb.go +41 -40
- package/x/vbank/vbank.go +25 -10
- package/x/vbank/vbank_test.go +213 -154
- package/x/vibc/handler.go +2 -1
- package/x/vibc/keeper/keeper.go +10 -10
- package/x/vibc/keeper/migrations.go +1 -1
- package/x/vibc/keeper/triggers.go +1 -1
- package/x/vibc/module.go +5 -22
- package/x/vibc/types/codec.go +2 -1
- package/x/vibc/types/expected_keepers.go +7 -5
- package/x/vibc/types/ibc_module.go +5 -5
- package/x/vibc/types/msgs.go +30 -7
- package/x/vibc/types/msgs.pb.go +29 -25
- package/x/vibc/types/receiver.go +2 -2
- package/x/vlocalchain/handler.go +2 -1
- package/x/vlocalchain/keeper/keeper.go +17 -5
- package/x/vlocalchain/keeper/keeper_test.go +3 -2
- package/x/vlocalchain/types/expected_keepers.go +7 -4
- package/x/vlocalchain/vlocalchain_test.go +38 -26
- package/x/vstorage/genesis.go +10 -10
- package/x/vstorage/handler.go +2 -1
- package/x/vstorage/keeper/keeper.go +68 -46
- package/x/vstorage/keeper/keeper_test.go +35 -19
- package/x/vstorage/module.go +27 -13
- package/x/vstorage/testing/queue.go +5 -3
- package/x/vstorage/vstorage.go +2 -1
- package/x/vstorage/vstorage_test.go +21 -17
- package/x/vtransfer/genesis.go +1 -3
- package/x/vtransfer/handler.go +3 -2
- package/x/vtransfer/ibc_middleware.go +5 -5
- package/x/vtransfer/ibc_middleware_test.go +43 -29
- package/x/vtransfer/keeper/keeper.go +35 -33
- package/x/vtransfer/module.go +8 -11
- package/x/vtransfer/types/expected_keepers.go +3 -3
- package/x/vtransfer/utils_test.go +26 -11
- package/daemon/cmd/testnet.go +0 -539
|
@@ -4,6 +4,7 @@ import (
|
|
|
4
4
|
"reflect"
|
|
5
5
|
"testing"
|
|
6
6
|
|
|
7
|
+
sdkmath "cosmossdk.io/math"
|
|
7
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
9
|
)
|
|
9
10
|
|
|
@@ -37,44 +38,44 @@ func TestAddStorageBeanCost(t *testing.T) {
|
|
|
37
38
|
},
|
|
38
39
|
{
|
|
39
40
|
name: "already_only_different",
|
|
40
|
-
in: []beans{NewStringBeans(BeansPerStorageByte,
|
|
41
|
-
want: []beans{NewStringBeans(BeansPerStorageByte,
|
|
41
|
+
in: []beans{NewStringBeans(BeansPerStorageByte, sdkmath.NewUint(123))},
|
|
42
|
+
want: []beans{NewStringBeans(BeansPerStorageByte, sdkmath.NewUint(123))},
|
|
42
43
|
},
|
|
43
44
|
{
|
|
44
45
|
name: "already_same",
|
|
45
46
|
in: []beans{
|
|
46
|
-
NewStringBeans("foo",
|
|
47
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
47
48
|
defaultStorageCost,
|
|
48
|
-
NewStringBeans("bar",
|
|
49
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
49
50
|
},
|
|
50
51
|
want: []beans{
|
|
51
|
-
NewStringBeans("foo",
|
|
52
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
52
53
|
defaultStorageCost,
|
|
53
|
-
NewStringBeans("bar",
|
|
54
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
{
|
|
57
58
|
name: "already_different",
|
|
58
59
|
in: []beans{
|
|
59
|
-
NewStringBeans("foo",
|
|
60
|
-
NewStringBeans(BeansPerStorageByte,
|
|
61
|
-
NewStringBeans("bar",
|
|
60
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
61
|
+
NewStringBeans(BeansPerStorageByte, sdkmath.NewUint(789)),
|
|
62
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
62
63
|
},
|
|
63
64
|
want: []beans{
|
|
64
|
-
NewStringBeans("foo",
|
|
65
|
-
NewStringBeans(BeansPerStorageByte,
|
|
66
|
-
NewStringBeans("bar",
|
|
65
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
66
|
+
NewStringBeans(BeansPerStorageByte, sdkmath.NewUint(789)),
|
|
67
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
67
68
|
},
|
|
68
69
|
},
|
|
69
70
|
{
|
|
70
71
|
name: "missing",
|
|
71
72
|
in: []beans{
|
|
72
|
-
NewStringBeans("foo",
|
|
73
|
-
NewStringBeans("bar",
|
|
73
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
74
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
74
75
|
},
|
|
75
76
|
want: []beans{
|
|
76
|
-
NewStringBeans("foo",
|
|
77
|
-
NewStringBeans("bar",
|
|
77
|
+
NewStringBeans("foo", sdkmath.NewUint(123)),
|
|
78
|
+
NewStringBeans("bar", sdkmath.NewUint(456)),
|
|
78
79
|
defaultStorageCost,
|
|
79
80
|
},
|
|
80
81
|
},
|
|
@@ -118,17 +119,17 @@ func TestUpdateParamsFromEmpty(t *testing.T) {
|
|
|
118
119
|
|
|
119
120
|
func TestUpdateParamsFromExisting(t *testing.T) {
|
|
120
121
|
defaultBeansPerUnit := DefaultBeansPerUnit()
|
|
121
|
-
customBeansPerUnit := NewStringBeans("foo",
|
|
122
|
+
customBeansPerUnit := NewStringBeans("foo", sdkmath.NewUint(1))
|
|
122
123
|
customPowerFlagFee := NewPowerFlagFee("bar", sdk.NewCoins(sdk.NewInt64Coin("baz", 2)))
|
|
123
124
|
customQueueSize := NewQueueSize("qux", int32(3))
|
|
124
|
-
customVatCleanup := UintMapEntry{"corge",
|
|
125
|
+
customVatCleanup := UintMapEntry{"corge", sdkmath.NewUint(4)}
|
|
125
126
|
in := Params{
|
|
126
127
|
BeansPerUnit: append([]StringBeans{customBeansPerUnit}, defaultBeansPerUnit[2:4]...),
|
|
127
128
|
BootstrapVatConfig: "",
|
|
128
129
|
FeeUnitPrice: sdk.NewCoins(sdk.NewInt64Coin("denom", 789)),
|
|
129
130
|
PowerFlagFees: []PowerFlagFee{customPowerFlagFee},
|
|
130
131
|
QueueMax: []QueueSize{NewQueueSize(QueueInbound, int32(10)), customQueueSize},
|
|
131
|
-
VatCleanupBudget: []UintMapEntry{customVatCleanup, UintMapEntry{VatCleanupDefault,
|
|
132
|
+
VatCleanupBudget: []UintMapEntry{customVatCleanup, UintMapEntry{VatCleanupDefault, sdkmath.NewUint(10)}},
|
|
132
133
|
}
|
|
133
134
|
want := Params{
|
|
134
135
|
BeansPerUnit: append(append(in.BeansPerUnit, defaultBeansPerUnit[0:2]...), defaultBeansPerUnit[4:]...),
|
|
@@ -161,7 +162,7 @@ func TestValidateParams(t *testing.T) {
|
|
|
161
162
|
t.Errorf("unexpected ValidateBasic() error with default params: %v", err)
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
customVatCleanup := UintMapEntry{"corge",
|
|
165
|
+
customVatCleanup := UintMapEntry{"corge", sdkmath.NewUint(4)}
|
|
165
166
|
params.VatCleanupBudget = append(params.VatCleanupBudget, customVatCleanup)
|
|
166
167
|
err = params.ValidateBasic()
|
|
167
168
|
if err != nil {
|
|
@@ -4,9 +4,12 @@
|
|
|
4
4
|
package types
|
|
5
5
|
|
|
6
6
|
import (
|
|
7
|
+
cosmossdk_io_math "cosmossdk.io/math"
|
|
7
8
|
fmt "fmt"
|
|
9
|
+
_ "github.com/cosmos/cosmos-proto"
|
|
8
10
|
github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types"
|
|
9
11
|
types "github.com/cosmos/cosmos-sdk/types"
|
|
12
|
+
_ "github.com/cosmos/cosmos-sdk/types/tx/amino"
|
|
10
13
|
_ "github.com/cosmos/gogoproto/gogoproto"
|
|
11
14
|
proto "github.com/cosmos/gogoproto/proto"
|
|
12
15
|
io "io"
|
|
@@ -298,7 +301,7 @@ type StringBeans struct {
|
|
|
298
301
|
// What the beans are for.
|
|
299
302
|
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
|
300
303
|
// The actual bean value.
|
|
301
|
-
Beans
|
|
304
|
+
Beans cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=beans,proto3,customtype=cosmossdk.io/math.Uint" json:"beans"`
|
|
302
305
|
}
|
|
303
306
|
|
|
304
307
|
func (m *StringBeans) Reset() { *m = StringBeans{} }
|
|
@@ -454,8 +457,8 @@ func (m *QueueSize) GetSize_() int32 {
|
|
|
454
457
|
// The value uses cosmos-sdk Uint rather than a native Go type to ensure that
|
|
455
458
|
// zeroes survive "omitempty" JSON serialization.
|
|
456
459
|
type UintMapEntry struct {
|
|
457
|
-
Key string
|
|
458
|
-
Value
|
|
460
|
+
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
|
|
461
|
+
Value cosmossdk_io_math.Uint `protobuf:"bytes,2,opt,name=value,proto3,customtype=cosmossdk.io/math.Uint" json:"value"`
|
|
459
462
|
}
|
|
460
463
|
|
|
461
464
|
func (m *UintMapEntry) Reset() { *m = UintMapEntry{} }
|
|
@@ -632,64 +635,67 @@ func init() {
|
|
|
632
635
|
func init() { proto.RegisterFile("agoric/swingset/swingset.proto", fileDescriptor_ff9c341e0de15f8b) }
|
|
633
636
|
|
|
634
637
|
var fileDescriptor_ff9c341e0de15f8b = []byte{
|
|
635
|
-
//
|
|
636
|
-
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55,
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
638
|
+
// 951 bytes of a gzipped FileDescriptorProto
|
|
639
|
+
0x1f, 0x8b, 0x08, 0x00, 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
|
660
|
+
0x99, 0x0a, 0x38, 0x5e, 0xed, 0x80, 0x0f, 0xe4, 0xe1, 0x45, 0x19, 0xd4, 0x86, 0x28, 0x45, 0x31,
|
|
661
|
+
0x87, 0xf7, 0xc1, 0xf5, 0x31, 0x46, 0x94, 0xcb, 0xb6, 0xfe, 0x8c, 0x12, 0xd1, 0xb2, 0x94, 0x02,
|
|
662
|
+
0xef, 0x5c, 0x51, 0x60, 0x24, 0x52, 0x42, 0x43, 0x57, 0x26, 0x1b, 0x11, 0x9a, 0xaa, 0x72, 0x88,
|
|
663
|
+
0xd3, 0x7d, 0x4a, 0x04, 0x7c, 0x02, 0xae, 0x4f, 0x31, 0x56, 0x3d, 0xfc, 0x24, 0x25, 0x81, 0x04,
|
|
664
|
+
0xa2, 0xb5, 0x34, 0xe2, 0xc8, 0xb5, 0x17, 0xd4, 0x21, 0xd4, 0xbd, 0x23, 0xdb, 0xfc, 0xf0, 0xbb,
|
|
665
|
+
0xbd, 0x1d, 0x12, 0xf1, 0x78, 0x36, 0xee, 0x04, 0x2c, 0x36, 0x6b, 0x37, 0x7f, 0x3b, 0x7c, 0x72,
|
|
666
|
+
0xd8, 0x15, 0x27, 0x09, 0xe6, 0xaa, 0x80, 0x7b, 0xcd, 0x29, 0xc6, 0x72, 0xda, 0x50, 0x0e, 0x80,
|
|
667
|
+
0x77, 0xc0, 0xfa, 0x98, 0x31, 0xc1, 0x45, 0x8a, 0x12, 0x7f, 0x8e, 0x84, 0x1f, 0x30, 0x3a, 0x25,
|
|
668
|
+
0x61, 0xab, 0xac, 0x16, 0x0c, 0xf3, 0xd8, 0xe7, 0x48, 0x0c, 0x54, 0x04, 0x7e, 0x0a, 0x56, 0x13,
|
|
669
|
+
0x76, 0x84, 0x53, 0x7f, 0x1a, 0xa1, 0xd0, 0x9f, 0x62, 0xcc, 0x5b, 0x15, 0x85, 0xf2, 0xd6, 0x15,
|
|
670
|
+
0xbe, 0x43, 0x99, 0x77, 0x2f, 0x42, 0xe1, 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xca, 0x0d, 0x6f, 0x01,
|
|
681
|
+
0x70, 0xb9, 0x26, 0x33, 0xa5, 0x9e, 0x8b, 0x0f, 0xbf, 0x02, 0xe5, 0x29, 0xfe, 0x5f, 0xee, 0x97,
|
|
682
|
+
0xec, 0x6b, 0x40, 0x7d, 0x04, 0xea, 0xb9, 0x24, 0xaf, 0xe0, 0x0b, 0x41, 0x85, 0x93, 0xa7, 0xfa,
|
|
683
|
+
0x69, 0xab, 0x7a, 0xea, 0x6c, 0x0a, 0x1f, 0x81, 0x66, 0x71, 0x59, 0xaf, 0xd6, 0x6a, 0x8e, 0xa2,
|
|
684
|
+
0x19, 0x7e, 0x5d, 0xad, 0x54, 0xb2, 0xe9, 0xfe, 0xb7, 0x05, 0x6a, 0x7b, 0x61, 0x8a, 0x39, 0x87,
|
|
685
|
+
0x77, 0xc1, 0x0a, 0x25, 0xc1, 0x21, 0x45, 0xb1, 0x79, 0xdf, 0xb9, 0xf6, 0x45, 0x66, 0xe7, 0xbe,
|
|
686
|
+
0x45, 0x66, 0xaf, 0xea, 0x17, 0xc0, 0xd2, 0xe3, 0x78, 0x79, 0x10, 0x3e, 0x02, 0x95, 0x04, 0xe3,
|
|
687
|
+
0x54, 0x41, 0x68, 0xba, 0xf7, 0x2f, 0x32, 0x5b, 0xd9, 0x8b, 0xcc, 0x6e, 0xe8, 0x22, 0x69, 0x39,
|
|
688
|
+
0x7f, 0x65, 0xf6, 0xce, 0x6b, 0x88, 0xd7, 0x0f, 0x82, 0xfe, 0x64, 0x22, 0x41, 0x79, 0xaa, 0x0b,
|
|
689
|
+
0xf4, 0x40, 0xe3, 0x72, 0x81, 0xfa, 0xad, 0x5a, 0x77, 0x77, 0xcf, 0x32, 0x1b, 0xe4, 0x7b, 0xe6,
|
|
690
|
+
0x17, 0x99, 0x0d, 0xf2, 0x9d, 0xf2, 0x45, 0x66, 0xdf, 0x30, 0x83, 0x73, 0x9f, 0xe3, 0x15, 0x12,
|
|
691
|
+
0x14, 0xff, 0x92, 0x23, 0x00, 0x1c, 0xc9, 0x2b, 0x3b, 0x12, 0x2c, 0xc5, 0xfd, 0x54, 0x90, 0x29,
|
|
692
|
+
0x0a, 0x04, 0xbc, 0x0d, 0x2a, 0x05, 0x19, 0x6e, 0x4a, 0x36, 0x46, 0x02, 0xc3, 0x46, 0xd3, 0x57,
|
|
693
|
+
0x4e, 0x99, 0x3c, 0x41, 0x02, 0x19, 0xea, 0x2a, 0x59, 0xda, 0x97, 0xc9, 0xd2, 0x72, 0x3c, 0xe5,
|
|
694
|
+
0xd4, 0x53, 0xdd, 0xfd, 0x67, 0x67, 0x6d, 0xeb, 0xf9, 0x59, 0xdb, 0x7a, 0x71, 0xd6, 0xb6, 0xbe,
|
|
695
|
+
0x3d, 0x6f, 0x97, 0x9e, 0x9f, 0xb7, 0x4b, 0xbf, 0x9e, 0xb7, 0x4b, 0x5f, 0xdc, 0x2d, 0xc8, 0xd3,
|
|
696
|
+
0xd7, 0x9f, 0x49, 0xfd, 0x64, 0x29, 0x79, 0x42, 0x16, 0x21, 0x1a, 0x2e, 0x75, 0x3b, 0xbe, 0xfc,
|
|
697
|
+
0x82, 0x2a, 0xdd, 0xc6, 0x35, 0xf5, 0x29, 0x7b, 0xff, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x42,
|
|
698
|
+
0x9d, 0xe4, 0x1c, 0x61, 0x07, 0x00, 0x00,
|
|
693
699
|
}
|
|
694
700
|
|
|
695
701
|
func (this *Params) Equal(that interface{}) bool {
|
package/x/vbank/genesis.go
CHANGED
|
@@ -4,7 +4,6 @@ import (
|
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
6
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
7
|
-
abci "github.com/cometbft/cometbft/abci/types"
|
|
8
7
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
9
8
|
)
|
|
10
9
|
|
|
@@ -29,15 +28,20 @@ func DefaultGenesisState() *types.GenesisState {
|
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
|
|
32
|
-
func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState)
|
|
31
|
+
func InitGenesis(ctx sdk.Context, keeper Keeper, data *types.GenesisState) {
|
|
33
32
|
keeper.SetParams(ctx, data.GetParams())
|
|
34
33
|
keeper.SetState(ctx, data.GetState())
|
|
35
|
-
return []abci.ValidatorUpdate{}
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
func ExportGenesis(ctx sdk.Context, k Keeper) *types.GenesisState {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
36
|
+
func ExportGenesis(ctx sdk.Context, k Keeper) (*types.GenesisState, error) {
|
|
37
|
+
params := k.GetParams(ctx)
|
|
38
|
+
state, err := k.GetState(ctx)
|
|
39
|
+
if err != nil {
|
|
40
|
+
return nil, fmt.Errorf("failed to export vbank state: %s", err)
|
|
41
|
+
}
|
|
42
|
+
gs := &types.GenesisState{
|
|
43
|
+
Params: params,
|
|
44
|
+
State: state,
|
|
45
|
+
}
|
|
46
|
+
return gs, nil
|
|
43
47
|
}
|
package/x/vbank/handler.go
CHANGED
|
@@ -4,12 +4,13 @@ import (
|
|
|
4
4
|
"fmt"
|
|
5
5
|
|
|
6
6
|
sdkioerrors "cosmossdk.io/errors"
|
|
7
|
+
"github.com/cosmos/cosmos-sdk/baseapp"
|
|
7
8
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
8
9
|
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
9
10
|
)
|
|
10
11
|
|
|
11
12
|
// NewHandler returns a handler for "vbank" type messages.
|
|
12
|
-
func NewHandler(keeper Keeper)
|
|
13
|
+
func NewHandler(keeper Keeper) baseapp.MsgServiceHandler {
|
|
13
14
|
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
|
14
15
|
switch msg := msg.(type) {
|
|
15
16
|
default:
|
|
@@ -21,7 +21,10 @@ func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types
|
|
|
21
21
|
// State queries state of distribution module
|
|
22
22
|
func (k Keeper) State(c context.Context, req *types.QueryStateRequest) (*types.QueryStateResponse, error) {
|
|
23
23
|
ctx := sdk.UnwrapSDKContext(c)
|
|
24
|
-
state := k.GetState(ctx)
|
|
24
|
+
state, err := k.GetState(ctx)
|
|
25
|
+
if err != nil {
|
|
26
|
+
return nil, err
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
return &types.QueryStateResponse{State: state}, nil
|
|
27
30
|
}
|
package/x/vbank/keeper/keeper.go
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
package keeper
|
|
2
2
|
|
|
3
3
|
import (
|
|
4
|
+
"context"
|
|
5
|
+
|
|
6
|
+
"cosmossdk.io/core/address"
|
|
7
|
+
storetypes "cosmossdk.io/core/store"
|
|
8
|
+
sdkerrors "cosmossdk.io/errors"
|
|
9
|
+
"cosmossdk.io/store/prefix"
|
|
4
10
|
"github.com/cosmos/cosmos-sdk/codec"
|
|
5
|
-
|
|
11
|
+
"github.com/cosmos/cosmos-sdk/runtime"
|
|
6
12
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
13
|
+
sdktypeserrors "github.com/cosmos/cosmos-sdk/types/errors"
|
|
7
14
|
|
|
8
15
|
"github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
|
|
9
16
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
|
@@ -13,21 +20,32 @@ import (
|
|
|
13
20
|
|
|
14
21
|
const stateKey string = "state"
|
|
15
22
|
|
|
23
|
+
// addressToUpdatePrefix is a map of addresses to the set of denoms that need a
|
|
24
|
+
// balance update. The denoms are stored as Coins, but we only use the denoms,
|
|
25
|
+
// not the amounts. This is in a transient store, so it is not persisted across
|
|
26
|
+
// blocks.
|
|
27
|
+
const addressToUpdatePrefix string = "addressToUpdate"
|
|
28
|
+
|
|
16
29
|
// Keeper maintains the link to data storage and exposes getter/setter methods for the various parts of the state machine
|
|
17
30
|
type Keeper struct {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
31
|
+
storeService storetypes.KVStoreService
|
|
32
|
+
tstoreService storetypes.TransientStoreService
|
|
33
|
+
cdc codec.Codec
|
|
34
|
+
paramSpace paramtypes.Subspace
|
|
21
35
|
|
|
22
36
|
accountKeeper types.AccountKeeper
|
|
23
37
|
bankKeeper types.BankKeeper
|
|
24
38
|
rewardDistributorName string
|
|
25
39
|
PushAction vm.ActionPusher
|
|
40
|
+
AddressToUpdate map[string]sdk.Coins // address string -> Coins
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
// NewKeeper creates a new vbank Keeper instance
|
|
29
44
|
func NewKeeper(
|
|
30
|
-
cdc codec.Codec,
|
|
45
|
+
cdc codec.Codec,
|
|
46
|
+
storeService storetypes.KVStoreService,
|
|
47
|
+
tstoreService storetypes.TransientStoreService,
|
|
48
|
+
paramSpace paramtypes.Subspace,
|
|
31
49
|
accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper,
|
|
32
50
|
rewardDistributorName string,
|
|
33
51
|
pushAction vm.ActionPusher,
|
|
@@ -38,8 +56,9 @@ func NewKeeper(
|
|
|
38
56
|
paramSpace = paramSpace.WithKeyTable(types.ParamKeyTable())
|
|
39
57
|
}
|
|
40
58
|
|
|
41
|
-
|
|
42
|
-
|
|
59
|
+
k := Keeper{
|
|
60
|
+
storeService: storeService,
|
|
61
|
+
tstoreService: tstoreService,
|
|
43
62
|
cdc: cdc,
|
|
44
63
|
paramSpace: paramSpace,
|
|
45
64
|
accountKeeper: accountKeeper,
|
|
@@ -47,6 +66,52 @@ func NewKeeper(
|
|
|
47
66
|
rewardDistributorName: rewardDistributorName,
|
|
48
67
|
PushAction: pushAction,
|
|
49
68
|
}
|
|
69
|
+
|
|
70
|
+
k.bankKeeper.AppendSendRestriction(k.monitorSend)
|
|
71
|
+
return k
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
func (k Keeper) monitorSend(
|
|
75
|
+
ctx context.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins,
|
|
76
|
+
) (sdk.AccAddress, error) {
|
|
77
|
+
sdkCtx := sdk.UnwrapSDKContext(ctx)
|
|
78
|
+
adStore := k.OpenAddressToUpdateStore(sdkCtx)
|
|
79
|
+
if err := k.ensureAddressUpdate(adStore, fromAddr, amt); err != nil {
|
|
80
|
+
return nil, sdkerrors.Wrap(sdktypeserrors.ErrInvalidRequest, err.Error())
|
|
81
|
+
}
|
|
82
|
+
if err := k.ensureAddressUpdate(adStore, toAddr, amt); err != nil {
|
|
83
|
+
return nil, sdkerrors.Wrap(sdktypeserrors.ErrInvalidRequest, err.Error())
|
|
84
|
+
}
|
|
85
|
+
return toAddr, nil
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// records that we want to emit a balance update for the address
|
|
89
|
+
// for the given denoms. We use the Coins only to track the set of
|
|
90
|
+
// denoms, not for the amounts.
|
|
91
|
+
func (k Keeper) ensureAddressUpdate(adStore prefix.Store, address sdk.AccAddress, denoms sdk.Coins) error {
|
|
92
|
+
if denoms.IsZero() {
|
|
93
|
+
return nil
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var newDenoms sdk.Coins
|
|
97
|
+
|
|
98
|
+
// Get the existing denoms for the address, or create a new set if it doesn't exist
|
|
99
|
+
if adStore.Has(address) {
|
|
100
|
+
// If we have existing denoms, parse them
|
|
101
|
+
bz := adStore.Get(address)
|
|
102
|
+
currentDenoms, err := sdk.ParseCoinsNormalized(string(bz))
|
|
103
|
+
if err != nil {
|
|
104
|
+
return sdkerrors.Wrap(sdktypeserrors.ErrInvalidRequest, err.Error())
|
|
105
|
+
}
|
|
106
|
+
newDenoms = currentDenoms
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
newDenoms = newDenoms.Add(denoms...)
|
|
110
|
+
|
|
111
|
+
// ensure the denoms are sorted before we store them
|
|
112
|
+
str := newDenoms.Sort().String()
|
|
113
|
+
adStore.Set(address, []byte(str))
|
|
114
|
+
return nil
|
|
50
115
|
}
|
|
51
116
|
|
|
52
117
|
func (k Keeper) GetBalance(ctx sdk.Context, addr sdk.AccAddress, denom string) sdk.Coin {
|
|
@@ -87,9 +152,13 @@ func (k Keeper) GetModuleAccountAddress(ctx sdk.Context, name string) sdk.AccAdd
|
|
|
87
152
|
return acct.GetAddress()
|
|
88
153
|
}
|
|
89
154
|
|
|
90
|
-
func (k Keeper)
|
|
155
|
+
func (k Keeper) AddressCodec() address.Codec {
|
|
156
|
+
return k.accountKeeper.AddressCodec()
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
func (k Keeper) IsAllowedMonitoringAccount(ctx sdk.Context, addr string) bool {
|
|
91
160
|
params := k.GetParams(ctx)
|
|
92
|
-
return params.IsAllowedMonitoringAccount(addr
|
|
161
|
+
return params.IsAllowedMonitoringAccount(addr)
|
|
93
162
|
}
|
|
94
163
|
|
|
95
164
|
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
|
|
@@ -101,23 +170,39 @@ func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
|
|
101
170
|
k.paramSpace.SetParamSet(ctx, ¶ms)
|
|
102
171
|
}
|
|
103
172
|
|
|
104
|
-
func (k Keeper) GetState(ctx sdk.Context) types.State {
|
|
105
|
-
store :=
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
173
|
+
func (k Keeper) GetState(ctx sdk.Context) (types.State, error) {
|
|
174
|
+
store := k.storeService.OpenKVStore(ctx)
|
|
175
|
+
var state types.State
|
|
176
|
+
bz, err := store.Get([]byte(stateKey))
|
|
177
|
+
if err != nil {
|
|
178
|
+
return state, err
|
|
179
|
+
}
|
|
180
|
+
return state, k.cdc.Unmarshal(bz, &state)
|
|
110
181
|
}
|
|
111
182
|
|
|
112
|
-
func (k Keeper) SetState(ctx sdk.Context, state types.State) {
|
|
113
|
-
store :=
|
|
114
|
-
bz := k.cdc.
|
|
115
|
-
|
|
183
|
+
func (k Keeper) SetState(ctx sdk.Context, state types.State) error {
|
|
184
|
+
store := k.storeService.OpenKVStore(ctx)
|
|
185
|
+
bz, err := k.cdc.Marshal(&state)
|
|
186
|
+
if err != nil {
|
|
187
|
+
return err
|
|
188
|
+
}
|
|
189
|
+
return store.Set([]byte(stateKey), bz)
|
|
116
190
|
}
|
|
117
191
|
|
|
118
|
-
func (k Keeper) GetNextSequence(ctx sdk.Context) uint64 {
|
|
119
|
-
state := k.GetState(ctx)
|
|
192
|
+
func (k Keeper) GetNextSequence(ctx sdk.Context) (uint64, error) {
|
|
193
|
+
state, err := k.GetState(ctx)
|
|
194
|
+
if err != nil {
|
|
195
|
+
return 0, err
|
|
196
|
+
}
|
|
120
197
|
state.LastSequence = state.GetLastSequence() + 1
|
|
121
|
-
k.SetState(ctx, state)
|
|
122
|
-
|
|
198
|
+
return state.LastSequence, k.SetState(ctx, state)
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
func (k Keeper) OpenAddressToUpdateStore(ctx sdk.Context) prefix.Store {
|
|
202
|
+
store := k.tstoreService.OpenTransientStore(ctx)
|
|
203
|
+
if store == nil {
|
|
204
|
+
panic("transient store is nil")
|
|
205
|
+
}
|
|
206
|
+
kvstore := runtime.KVStoreAdapter(store)
|
|
207
|
+
return prefix.NewStore(kvstore, []byte(addressToUpdatePrefix))
|
|
123
208
|
}
|
|
@@ -21,7 +21,10 @@ func queryParams(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, leg
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
func queryState(ctx sdk.Context, _ []string, _ abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
|
|
24
|
-
state := k.GetState(ctx)
|
|
24
|
+
state, err := k.GetState(ctx)
|
|
25
|
+
if err != nil {
|
|
26
|
+
return nil, err
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
res, err := codec.MarshalJSONIndent(legacyQuerierCdc, state)
|
|
27
30
|
if err != nil {
|
|
@@ -3,6 +3,7 @@ package keeper
|
|
|
3
3
|
import (
|
|
4
4
|
"strings"
|
|
5
5
|
|
|
6
|
+
sdkmath "cosmossdk.io/math"
|
|
6
7
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
7
8
|
)
|
|
8
9
|
|
|
@@ -32,7 +33,7 @@ func minCoins(a, b sdk.Coins) sdk.Coins {
|
|
|
32
33
|
return sdk.NewCoins(min...)
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
func mulCoins(a sdk.Coins, b
|
|
36
|
+
func mulCoins(a sdk.Coins, b sdkmath.LegacyDec) sdk.Coins {
|
|
36
37
|
coins := make([]sdk.Coin, 0, len(a))
|
|
37
38
|
for _, coin := range a {
|
|
38
39
|
amount := b.MulInt(coin.Amount).TruncateInt()
|
|
@@ -46,7 +47,10 @@ func mulCoins(a sdk.Coins, b sdk.Dec) sdk.Coins {
|
|
|
46
47
|
// DistributeRewards drives the rewards state machine.
|
|
47
48
|
func (k Keeper) DistributeRewards(ctx sdk.Context) error {
|
|
48
49
|
// Distribute rewards.
|
|
49
|
-
state := k.GetState(ctx)
|
|
50
|
+
state, err := k.GetState(ctx)
|
|
51
|
+
if err != nil {
|
|
52
|
+
return err
|
|
53
|
+
}
|
|
50
54
|
params := k.GetParams(ctx)
|
|
51
55
|
|
|
52
56
|
smoothingBlocks := params.GetSmoothingBlocks()
|