@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.
Files changed (113) hide show
  1. package/CHANGELOG.md +11 -187
  2. package/Makefile +2 -2
  3. package/ante/ante.go +2 -2
  4. package/ante/inbound.go +1 -2
  5. package/ante/inbound_test.go +3 -1
  6. package/ante/vm_admission.go +1 -2
  7. package/app/app.go +255 -174
  8. package/app/encoding.go +6 -3
  9. package/app/export.go +50 -21
  10. package/app/genesis.go +7 -5
  11. package/app/params/encoding.go +1 -1
  12. package/app/params/proto.go +6 -4
  13. package/app/sim_test.go +11 -13
  14. package/app/txconfig/tx_config.go +169 -0
  15. package/app/upgrade.go +52 -97
  16. package/app/upgrade_test.go +1 -1
  17. package/cmd/agd/agvm.go +1 -1
  18. package/cmd/agd/main.go +1 -1
  19. package/cmd/libdaemon/main.go +2 -2
  20. package/daemon/cmd/root.go +99 -30
  21. package/daemon/cmd/root_test.go +12 -27
  22. package/daemon/main.go +2 -9
  23. package/git-revision.txt +1 -1
  24. package/go.mod +129 -109
  25. package/go.sum +228 -469
  26. package/package.json +2 -2
  27. package/proto/agoric/swingset/msgs.proto +46 -9
  28. package/proto/agoric/swingset/swingset.proto +7 -2
  29. package/proto/agoric/vbank/vbank.proto +1 -1
  30. package/proto/agoric/vibc/msgs.proto +4 -0
  31. package/tests/e2e/vbank/vbank_test.go +172 -0
  32. package/tests/integrations/types/aminojson_test.go +214 -0
  33. package/tests/integrations/vbank/vbank_test.go +348 -0
  34. package/third_party/proto/amino/amino.proto +6 -1
  35. package/third_party/proto/cosmos/base/v1beta1/coin.proto +18 -5
  36. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +4 -8
  37. package/third_party/proto/ibc/core/channel/v1/channel.proto +42 -17
  38. package/third_party/proto/ibc/core/client/v1/client.proto +48 -40
  39. package/types/address_hooks.go +2 -2
  40. package/types/address_hooks_test.go +3 -3
  41. package/types/ibc_packet.go +3 -3
  42. package/types/ibc_packet_test.go +3 -3
  43. package/types/kv_entry_helpers.go +3 -3
  44. package/types/kv_entry_helpers_test.go +2 -2
  45. package/types/legacy_address_encoder.go +58 -0
  46. package/vm/proto_json_test.go +1 -1
  47. package/vm/server.go +2 -1
  48. package/x/swingset/abci.go +2 -2
  49. package/x/swingset/client/cli/tx.go +16 -14
  50. package/x/swingset/config.go +1 -1
  51. package/x/swingset/genesis.go +2 -1
  52. package/x/swingset/handler.go +2 -1
  53. package/x/swingset/keeper/extension_snapshotter.go +14 -5
  54. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  55. package/x/swingset/keeper/keeper.go +21 -17
  56. package/x/swingset/keeper/keeper_test.go +10 -7
  57. package/x/swingset/keeper/msg_server.go +26 -5
  58. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  59. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  60. package/x/swingset/module.go +20 -22
  61. package/x/swingset/types/codec.go +10 -5
  62. package/x/swingset/types/default-params.go +13 -12
  63. package/x/swingset/types/expected_keepers.go +5 -4
  64. package/x/swingset/types/msgs.go +50 -36
  65. package/x/swingset/types/msgs.pb.go +60 -51
  66. package/x/swingset/types/params_test.go +21 -20
  67. package/x/swingset/types/swingset.pb.go +67 -61
  68. package/x/vbank/genesis.go +12 -8
  69. package/x/vbank/handler.go +2 -1
  70. package/x/vbank/keeper/grpc_query.go +4 -1
  71. package/x/vbank/keeper/keeper.go +108 -23
  72. package/x/vbank/keeper/querier.go +4 -1
  73. package/x/vbank/keeper/rewards.go +6 -2
  74. package/x/vbank/module.go +47 -75
  75. package/x/vbank/types/expected_keepers.go +15 -10
  76. package/x/vbank/types/key.go +3 -0
  77. package/x/vbank/types/params.go +4 -3
  78. package/x/vbank/types/vbank.pb.go +41 -40
  79. package/x/vbank/vbank.go +25 -10
  80. package/x/vbank/vbank_test.go +213 -154
  81. package/x/vibc/handler.go +2 -1
  82. package/x/vibc/keeper/keeper.go +10 -10
  83. package/x/vibc/keeper/migrations.go +1 -1
  84. package/x/vibc/keeper/triggers.go +1 -1
  85. package/x/vibc/module.go +5 -22
  86. package/x/vibc/types/codec.go +2 -1
  87. package/x/vibc/types/expected_keepers.go +7 -5
  88. package/x/vibc/types/ibc_module.go +5 -5
  89. package/x/vibc/types/msgs.go +30 -7
  90. package/x/vibc/types/msgs.pb.go +29 -25
  91. package/x/vibc/types/receiver.go +2 -2
  92. package/x/vlocalchain/handler.go +2 -1
  93. package/x/vlocalchain/keeper/keeper.go +17 -5
  94. package/x/vlocalchain/keeper/keeper_test.go +3 -2
  95. package/x/vlocalchain/types/expected_keepers.go +7 -4
  96. package/x/vlocalchain/vlocalchain_test.go +38 -26
  97. package/x/vstorage/genesis.go +10 -10
  98. package/x/vstorage/handler.go +2 -1
  99. package/x/vstorage/keeper/keeper.go +68 -46
  100. package/x/vstorage/keeper/keeper_test.go +35 -19
  101. package/x/vstorage/module.go +27 -13
  102. package/x/vstorage/testing/queue.go +5 -3
  103. package/x/vstorage/vstorage.go +2 -1
  104. package/x/vstorage/vstorage_test.go +21 -17
  105. package/x/vtransfer/genesis.go +1 -3
  106. package/x/vtransfer/handler.go +3 -2
  107. package/x/vtransfer/ibc_middleware.go +5 -5
  108. package/x/vtransfer/ibc_middleware_test.go +43 -29
  109. package/x/vtransfer/keeper/keeper.go +35 -33
  110. package/x/vtransfer/module.go +8 -11
  111. package/x/vtransfer/types/expected_keepers.go +3 -3
  112. package/x/vtransfer/utils_test.go +26 -11
  113. 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, sdk.NewUint(123))},
41
- want: []beans{NewStringBeans(BeansPerStorageByte, sdk.NewUint(123))},
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", sdk.NewUint(123)),
47
+ NewStringBeans("foo", sdkmath.NewUint(123)),
47
48
  defaultStorageCost,
48
- NewStringBeans("bar", sdk.NewUint(456)),
49
+ NewStringBeans("bar", sdkmath.NewUint(456)),
49
50
  },
50
51
  want: []beans{
51
- NewStringBeans("foo", sdk.NewUint(123)),
52
+ NewStringBeans("foo", sdkmath.NewUint(123)),
52
53
  defaultStorageCost,
53
- NewStringBeans("bar", sdk.NewUint(456)),
54
+ NewStringBeans("bar", sdkmath.NewUint(456)),
54
55
  },
55
56
  },
56
57
  {
57
58
  name: "already_different",
58
59
  in: []beans{
59
- NewStringBeans("foo", sdk.NewUint(123)),
60
- NewStringBeans(BeansPerStorageByte, sdk.NewUint(789)),
61
- NewStringBeans("bar", sdk.NewUint(456)),
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", sdk.NewUint(123)),
65
- NewStringBeans(BeansPerStorageByte, sdk.NewUint(789)),
66
- NewStringBeans("bar", sdk.NewUint(456)),
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", sdk.NewUint(123)),
73
- NewStringBeans("bar", sdk.NewUint(456)),
73
+ NewStringBeans("foo", sdkmath.NewUint(123)),
74
+ NewStringBeans("bar", sdkmath.NewUint(456)),
74
75
  },
75
76
  want: []beans{
76
- NewStringBeans("foo", sdk.NewUint(123)),
77
- NewStringBeans("bar", sdk.NewUint(456)),
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", sdk.NewUint(1))
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", sdk.NewUint(4)}
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, sdk.NewUint(10)}},
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", sdk.NewUint(4)}
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 github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=beans,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"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 `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
458
- Value github_com_cosmos_cosmos_sdk_types.Uint `protobuf:"bytes,2,opt,name=value,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Uint" json:"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
- // 897 bytes of a gzipped FileDescriptorProto
636
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0x4d, 0x6f, 0xe3, 0x44,
637
- 0x18, 0x8e, 0xc9, 0x07, 0xcd, 0x9b, 0x6c, 0x5b, 0x86, 0x4a, 0x1b, 0x2a, 0x36, 0xae, 0x7c, 0xa1,
638
- 0xd2, 0x6a, 0x93, 0x2d, 0x08, 0x21, 0x65, 0xc5, 0x21, 0x8e, 0xb2, 0x5a, 0x09, 0x2d, 0xca, 0x3a,
639
- 0x2a, 0x07, 0x04, 0xb2, 0x26, 0xce, 0xc4, 0x4c, 0xeb, 0x78, 0xbc, 0x9e, 0x49, 0xda, 0xee, 0x1f,
640
- 0x80, 0x23, 0xe2, 0xc4, 0xb1, 0x67, 0x7e, 0xc9, 0x1e, 0xf7, 0x88, 0x38, 0x98, 0x55, 0x7b, 0x41,
641
- 0x3d, 0xe6, 0x88, 0x84, 0x84, 0xe6, 0x23, 0xae, 0x45, 0x17, 0x51, 0x21, 0xed, 0xc9, 0xf3, 0x7e,
642
- 0x3f, 0xef, 0xf3, 0x8c, 0x6d, 0x68, 0xe3, 0x90, 0xa5, 0x34, 0xe8, 0xf2, 0x13, 0x1a, 0x87, 0x9c,
643
- 0x88, 0xfc, 0xd0, 0x49, 0x52, 0x26, 0x18, 0xda, 0xd2, 0xf1, 0xce, 0xda, 0xbd, 0xbb, 0x13, 0xb2,
644
- 0x90, 0xa9, 0x58, 0x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x73, 0x42, 0x70, 0xcc, 0x65, 0x5b, 0x7f, 0x11, 0x53, 0xd1, 0xb2, 0xd4, 0x16,
656
- 0x1f, 0xde, 0xd8, 0x62, 0x2c, 0x52, 0x1a, 0x87, 0xae, 0x4c, 0x36, 0x8b, 0x34, 0x55, 0xe5, 0x88,
657
- 0xa4, 0x87, 0x31, 0x15, 0xe8, 0x39, 0x6c, 0xce, 0x08, 0x51, 0x3d, 0xfc, 0x24, 0xa5, 0x81, 0x04,
658
- 0xa2, 0xf9, 0xd0, 0x62, 0x74, 0xa4, 0x18, 0x1d, 0x23, 0x46, 0x67, 0xc0, 0x68, 0xec, 0x3e, 0x94,
659
- 0x6d, 0x7e, 0xf9, 0xdd, 0xde, 0x0f, 0xa9, 0xf8, 0x6e, 0x31, 0xe9, 0x04, 0x6c, 0xde, 0x35, 0xca,
660
- 0xe9, 0xc7, 0x03, 0x3e, 0x3d, 0xee, 0x8a, 0xb3, 0x84, 0x70, 0x55, 0xc0, 0xbd, 0xe6, 0x8c, 0x10,
661
- 0x39, 0x6d, 0x24, 0x07, 0xa0, 0x87, 0xb0, 0x33, 0x61, 0x4c, 0x70, 0x91, 0xe2, 0xc4, 0x5f, 0x62,
662
- 0xe1, 0x07, 0x2c, 0x9e, 0xd1, 0xb0, 0x55, 0x56, 0x22, 0xa1, 0x3c, 0xf6, 0x15, 0x16, 0x03, 0x15,
663
- 0x41, 0x5f, 0xc0, 0x56, 0xc2, 0x4e, 0x48, 0xea, 0xcf, 0x22, 0x1c, 0xfa, 0x33, 0x42, 0x78, 0xab,
664
- 0xa2, 0x50, 0xde, 0xbb, 0xb1, 0xef, 0x48, 0xe6, 0x3d, 0x8e, 0x70, 0xf8, 0x98, 0x10, 0xb3, 0xf0,
665
- 0x9d, 0xa4, 0xe0, 0xe3, 0xe8, 0x73, 0xa8, 0x3f, 0x5f, 0x90, 0x05, 0xf1, 0xe7, 0xf8, 0xb4, 0x55,
666
- 0x55, 0x6d, 0x76, 0x6f, 0xb4,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5e, 0x5f, 0xb4, 0xad, 0x1f, 0x2f, 0xdb, 0xa5, 0x57, 0x97, 0xed,
689
- 0xd2, 0xaf, 0x97, 0xed, 0xd2, 0xd7, 0x8f, 0x0a, 0xf4, 0xf4, 0xf5, 0xef, 0x4d, 0xbf, 0x7b, 0x8a,
690
- 0x9e, 0x90, 0x45, 0x38, 0x0e, 0xd7, 0xbc, 0x9d, 0x5e, 0xff, 0xf9, 0x14, 0x6f, 0x93, 0x9a, 0xfa,
691
- 0x61, 0x7d, 0xf2, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xec, 0x66, 0x1a, 0x0f, 0x19, 0x07, 0x00,
692
- 0x00,
638
+ // 951 bytes of a gzipped FileDescriptorProto
639
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xcb, 0x6f, 0x1b, 0x45,
640
+ 0x1c, 0xf6, 0xe2, 0x07, 0xf1, 0xd8, 0x6d, 0xd2, 0x21, 0xa2, 0x4e, 0x44, 0xbd, 0xd1, 0x9e, 0x22,
641
+ 0xaa, 0xd8, 0x0d, 0x0f, 0x21, 0xb9, 0x42, 0xc2, 0x6b, 0xa5, 0xaa, 0x84, 0x8a, 0xdc, 0xb5, 0xc2,
642
+ 0x01, 0x8a, 0x56, 0xe3, 0xf5, 0x78, 0x3b, 0xc9, 0xee, 0xcc, 0x76, 0x67, 0xec, 0x24, 0xfd, 0x0b,
643
+ 0x10, 0x27, 0xc4, 0x89, 0x63, 0xce, 0x9c, 0x38, 0xf0, 0x1f, 0x70, 0xa9, 0x38, 0xf5, 0x88, 0x38,
644
+ 0x2c, 0x55, 0x72, 0x00, 0xe5, 0xe8, 0x23, 0x12, 0x12, 0x9a, 0x87, 0x37, 0xab, 0xa6, 0x88, 0x5e,
645
+ 0xb8, 0xd8, 0xf3, 0x7b, 0x7f, 0xdf, 0xf7, 0x9b, 0xdd, 0x05, 0x6d, 0x14, 0xb2, 0x94, 0x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xcf, 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 {
@@ -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) []abci.ValidatorUpdate {
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
- var gs types.GenesisState
40
- gs.Params = k.GetParams(ctx)
41
- gs.State = k.GetState(ctx)
42
- return &gs
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
  }
@@ -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) sdk.Handler {
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
  }
@@ -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
- storetypes "github.com/cosmos/cosmos-sdk/store/types"
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
- storeKey storetypes.StoreKey
19
- cdc codec.Codec
20
- paramSpace paramtypes.Subspace
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, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
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
- return Keeper{
42
- storeKey: key,
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) IsAllowedMonitoringAccount(ctx sdk.Context, addr sdk.AccAddress) bool {
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.String())
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, &params)
102
171
  }
103
172
 
104
- func (k Keeper) GetState(ctx sdk.Context) types.State {
105
- store := ctx.KVStore(k.storeKey)
106
- bz := store.Get([]byte(stateKey))
107
- state := types.State{}
108
- k.cdc.MustUnmarshal(bz, &state)
109
- return state
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 := ctx.KVStore(k.storeKey)
114
- bz := k.cdc.MustMarshal(&state)
115
- store.Set([]byte(stateKey), bz)
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
- return state.LastSequence
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 sdk.Dec) sdk.Coins {
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()