@agoric/cosmos 0.34.2-dev-9f6644d.0 → 0.34.2-dev-0467291.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 (109) hide show
  1. package/.clang-format +116 -0
  2. package/Makefile +38 -67
  3. package/ante/ante.go +2 -2
  4. package/ante/inbound_test.go +1 -1
  5. package/app/app.go +173 -142
  6. package/app/export.go +6 -6
  7. package/app/genesis.go +4 -0
  8. package/app/sim_test.go +299 -50
  9. package/app/upgrade.go +70 -3
  10. package/cmd/agd/agvm.go +1 -1
  11. package/cmd/agd/main.go +1 -1
  12. package/cmd/libdaemon/main.go +1 -1
  13. package/daemon/cmd/root.go +25 -34
  14. package/daemon/cmd/root_test.go +5 -4
  15. package/daemon/cmd/testnet.go +221 -95
  16. package/daemon/main.go +1 -0
  17. package/git-revision.txt +1 -1
  18. package/go.mod +93 -58
  19. package/go.sum +148 -95
  20. package/package.json +2 -2
  21. package/proto/agoric/swingset/genesis.proto +7 -11
  22. package/proto/agoric/swingset/msgs.proto +56 -75
  23. package/proto/agoric/swingset/query.proto +7 -10
  24. package/proto/agoric/swingset/swingset.proto +79 -108
  25. package/proto/agoric/vbank/genesis.proto +5 -5
  26. package/proto/agoric/vbank/msgs.proto +1 -2
  27. package/proto/agoric/vbank/vbank.proto +42 -52
  28. package/proto/agoric/vibc/msgs.proto +8 -11
  29. package/proto/agoric/vstorage/genesis.proto +6 -9
  30. package/proto/agoric/vstorage/query.proto +19 -48
  31. package/proto/agoric/vstorage/vstorage.proto +4 -10
  32. package/proto/agoric/vtransfer/genesis.proto +7 -7
  33. package/proto/buf.gen.gogo.yaml +8 -0
  34. package/proto/buf.gen.pulsar.yaml +17 -0
  35. package/proto/buf.gen.swagger.yaml +5 -0
  36. package/proto/buf.yaml +10 -0
  37. package/scripts/protocgen.sh +14 -21
  38. package/third_party/proto/amino/amino.proto +79 -0
  39. package/third_party/proto/cosmos/base/v1beta1/coin.proto +7 -2
  40. package/third_party/proto/cosmos/ics23/v1/proofs.proto +243 -0
  41. package/third_party/proto/cosmos/msg/v1/msg.proto +30 -0
  42. package/third_party/proto/cosmos/upgrade/v1beta1/upgrade.proto +17 -5
  43. package/third_party/proto/cosmos_proto/cosmos.proto +16 -1
  44. package/third_party/proto/gogoproto/gogo.proto +2 -2
  45. package/third_party/proto/google/protobuf/any.proto +6 -3
  46. package/third_party/proto/ibc/core/channel/v1/channel.proto +1 -1
  47. package/third_party/proto/ibc/core/client/v1/client.proto +4 -2
  48. package/types/address_hooks.go +2 -2
  49. package/types/address_hooks_test.go +3 -3
  50. package/types/ibc_packet.go +3 -3
  51. package/types/ibc_packet_test.go +3 -3
  52. package/vm/proto_json.go +2 -2
  53. package/x/swingset/abci.go +1 -1
  54. package/x/swingset/alias.go +0 -1
  55. package/x/swingset/config.go +1 -1
  56. package/x/swingset/keeper/extension_snapshotter.go +1 -1
  57. package/x/swingset/keeper/extension_snapshotter_test.go +1 -1
  58. package/x/swingset/keeper/keeper.go +1 -1
  59. package/x/swingset/keeper/keeper_test.go +1 -1
  60. package/x/swingset/keeper/querier.go +1 -30
  61. package/x/swingset/keeper/swing_store_exports_handler.go +1 -1
  62. package/x/swingset/keeper/swing_store_exports_handler_test.go +1 -1
  63. package/x/swingset/module.go +1 -14
  64. package/x/swingset/types/genesis.pb.go +2 -2
  65. package/x/swingset/types/msgs.pb.go +4 -3
  66. package/x/swingset/types/msgs_test.go +1 -1
  67. package/x/swingset/types/query.pb.go +4 -3
  68. package/x/swingset/types/swingset.pb.go +2 -2
  69. package/x/vbank/genesis.go +1 -1
  70. package/x/vbank/keeper/querier.go +1 -21
  71. package/x/vbank/module.go +1 -16
  72. package/x/vbank/types/genesis.pb.go +2 -2
  73. package/x/vbank/types/msgs.pb.go +3 -2
  74. package/x/vbank/types/query.pb.go +4 -3
  75. package/x/vbank/types/vbank.pb.go +2 -2
  76. package/x/vbank/vbank_test.go +16 -16
  77. package/x/vibc/keeper/keeper.go +8 -5
  78. package/x/vibc/keeper/migrations.go +36 -0
  79. package/x/vibc/keeper/triggers.go +1 -1
  80. package/x/vibc/module.go +9 -17
  81. package/x/vibc/types/expected_keepers.go +5 -10
  82. package/x/vibc/types/ibc_module.go +4 -4
  83. package/x/vibc/types/msgs.go +1 -1
  84. package/x/vibc/types/msgs.pb.go +5 -4
  85. package/x/vibc/types/receiver.go +2 -2
  86. package/x/vlocalchain/keeper/keeper.go +3 -3
  87. package/x/vlocalchain/types/vlocalchain.pb.go +1 -1
  88. package/x/vlocalchain/vlocalchain_test.go +6 -6
  89. package/x/vstorage/alias.go +0 -1
  90. package/x/vstorage/client/cli/query.go +1 -1
  91. package/x/vstorage/genesis.go +1 -1
  92. package/x/vstorage/keeper/keeper.go +6 -5
  93. package/x/vstorage/keeper/keeper_test.go +24 -24
  94. package/x/vstorage/keeper/querier.go +1 -32
  95. package/x/vstorage/keeper/querier_test.go +41 -6
  96. package/x/vstorage/module.go +1 -14
  97. package/x/vstorage/types/genesis.pb.go +2 -2
  98. package/x/vstorage/types/query.pb.go +8 -5
  99. package/x/vstorage/types/vstorage.pb.go +2 -2
  100. package/x/vstorage/vstorage_test.go +3 -3
  101. package/x/vtransfer/genesis.go +1 -1
  102. package/x/vtransfer/ibc_middleware.go +4 -4
  103. package/x/vtransfer/ibc_middleware_test.go +10 -11
  104. package/x/vtransfer/keeper/keeper.go +5 -5
  105. package/x/vtransfer/module.go +1 -14
  106. package/x/vtransfer/types/expected_keepers.go +2 -18
  107. package/x/vtransfer/types/genesis.pb.go +2 -2
  108. package/x/vtransfer/utils_test.go +15 -15
  109. package/daemon/cmd/genaccounts.go +0 -195
@@ -14,18 +14,15 @@ service Msg {
14
14
 
15
15
  // MsgSendPacket is an SDK message for sending an outgoing IBC packet
16
16
  message MsgSendPacket {
17
- option (gogoproto.equal) = false;
17
+ option (gogoproto.equal) = false;
18
18
 
19
- ibc.core.channel.v1.Packet packet = 1 [
20
- (gogoproto.nullable) = false,
21
- (gogoproto.jsontag) = "packet",
22
- (gogoproto.moretags) = "yaml:\"packet\""
23
- ];
24
- bytes sender = 2 [
25
- (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
26
- (gogoproto.jsontag) = "submitter",
27
- (gogoproto.moretags) = "yaml:\"submitter\""
28
- ];
19
+ ibc.core.channel.v1.Packet packet = 1
20
+ [(gogoproto.nullable) = false, (gogoproto.jsontag) = "packet", (gogoproto.moretags) = "yaml:\"packet\""];
21
+ bytes sender = 2 [
22
+ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
23
+ (gogoproto.jsontag) = "submitter",
24
+ (gogoproto.moretags) = "yaml:\"submitter\""
25
+ ];
29
26
  }
30
27
 
31
28
  // Empty response for SendPacket.
@@ -7,19 +7,16 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types
7
7
 
8
8
  // The initial or exported state.
9
9
  message GenesisState {
10
- option (gogoproto.equal) = false;
10
+ option (gogoproto.equal) = false;
11
11
 
12
- repeated DataEntry data = 1 [
13
- (gogoproto.jsontag) = "data",
14
- (gogoproto.moretags) = "yaml:\"data\""
15
- ];
12
+ repeated DataEntry data = 1 [(gogoproto.jsontag) = "data", (gogoproto.moretags) = "yaml:\"data\""];
16
13
  }
17
14
 
18
15
  // A vstorage entry. The only necessary entries are those with data, as the
19
16
  // ancestor nodes are reconstructed on import.
20
17
  message DataEntry {
21
- // A "."-separated path with individual path elements matching
22
- // `[-_A-Za-z0-9]+`
23
- string path = 1;
24
- string value = 2;
18
+ // A "."-separated path with individual path elements matching
19
+ // `[-_A-Za-z0-9]+`
20
+ string path = 1;
21
+ string value = 2;
25
22
  }
@@ -16,95 +16,66 @@ service Query {
16
16
 
17
17
  // Return a formatted representation of a vstorage datum that must be
18
18
  // a valid StreamCell with CapData values, or standalone CapData.
19
- rpc CapData(QueryCapDataRequest)
20
- returns (QueryCapDataResponse) {
21
- option (google.api.http).get = "/agoric/vstorage/capdata/{path}";
19
+ rpc CapData(QueryCapDataRequest) returns (QueryCapDataResponse) {
20
+ option (google.api.http).get = "/agoric/vstorage/capdata/{path}";
22
21
  }
23
22
 
24
23
  // Return the children of a given vstorage path.
25
- rpc Children(QueryChildrenRequest)
26
- returns (QueryChildrenResponse) {
27
- option (google.api.http).get = "/agoric/vstorage/children/{path}";
24
+ rpc Children(QueryChildrenRequest) returns (QueryChildrenResponse) {
25
+ option (google.api.http).get = "/agoric/vstorage/children/{path}";
28
26
  }
29
27
  }
30
28
 
31
29
  // QueryDataRequest is the vstorage path data query.
32
30
  message QueryDataRequest {
33
- string path = 1 [
34
- (gogoproto.jsontag) = "path",
35
- (gogoproto.moretags) = "yaml:\"path\""
36
- ];
31
+ string path = 1 [(gogoproto.jsontag) = "path", (gogoproto.moretags) = "yaml:\"path\""];
37
32
  }
38
33
 
39
34
  // QueryDataResponse is the vstorage path data response.
40
35
  message QueryDataResponse {
41
- string value = 1 [
42
- (gogoproto.jsontag) = "value",
43
- (gogoproto.moretags) = "yaml:\"value\""
44
- ];
36
+ string value = 1 [(gogoproto.jsontag) = "value", (gogoproto.moretags) = "yaml:\"value\""];
45
37
  }
46
38
 
47
39
  // QueryCapDataRequest contains a path and formatting configuration.
48
40
  message QueryCapDataRequest {
49
- string path = 1 [
50
- (gogoproto.jsontag) = "path",
51
- (gogoproto.moretags) = "yaml:\"path\""
52
- ];
41
+ string path = 1 [(gogoproto.jsontag) = "path", (gogoproto.moretags) = "yaml:\"path\""];
53
42
  // mediaType must be an actual media type in the registry at
54
43
  // https://www.iana.org/assignments/media-types/media-types.xhtml
55
44
  // or a special value that does not conflict with the media type syntax.
56
45
  // The only valid value is "JSON Lines", which is also the default.
57
- string media_type = 2 [
58
- (gogoproto.jsontag) = "mediaType",
59
- (gogoproto.moretags) = "yaml:\"mediaType\""
60
- ];
46
+ string media_type = 2 [(gogoproto.jsontag) = "mediaType", (gogoproto.moretags) = "yaml:\"mediaType\""];
61
47
  // itemFormat, if present, must be the special value "flat" to indicate that
62
48
  // the deep structure of each item should be flattened into a single level
63
49
  // with kebab-case keys (e.g., `{ "metrics": { "min": 0, "max": 88 } }` as
64
50
  // `{ "metrics-min": 0, "metrics-max": 88 }`).
65
- string item_format = 3 [
66
- (gogoproto.jsontag) = "itemFormat",
67
- (gogoproto.moretags) = "yaml:\"itemFormat\""
68
- ];
51
+ string item_format = 3 [(gogoproto.jsontag) = "itemFormat", (gogoproto.moretags) = "yaml:\"itemFormat\""];
69
52
  // remotableValueFormat indicates how to transform references to opaque but
70
53
  // distinguishable Remotables into readable embedded representations.
71
- // * "object" represents each Remotable as an `{ id, allegedName }` object, e.g. `{ "id": "board007", "allegedName": "IST brand" }`.
72
- // * "string" represents each Remotable as a string with bracket-wrapped contents including its alleged name and id, e.g. "[Alleged: IST brand <board007>]".
73
- string remotable_value_format = 10 [
74
- (gogoproto.jsontag) = "remotableValueFormat",
75
- (gogoproto.moretags) = "yaml:\"remotableValueFormat\""
76
- ];
54
+ // * "object" represents each Remotable as an `{ id, allegedName }` object, e.g. `{ "id": "board007", "allegedName":
55
+ // "IST brand" }`.
56
+ // * "string" represents each Remotable as a string with bracket-wrapped contents including its alleged name and id,
57
+ // e.g. "[Alleged: IST brand <board007>]".
58
+ string remotable_value_format = 10
59
+ [(gogoproto.jsontag) = "remotableValueFormat", (gogoproto.moretags) = "yaml:\"remotableValueFormat\""];
77
60
  }
78
61
 
79
62
  // QueryCapDataResponse represents the result with the requested formatting,
80
63
  // reserving space for future metadata such as media type.
81
64
  message QueryCapDataResponse {
82
- string block_height = 1 [
83
- (gogoproto.jsontag) = "blockHeight",
84
- (gogoproto.moretags) = "yaml:\"blockHeight\""
85
- ];
86
- string value = 10 [
87
- (gogoproto.jsontag) = "value",
88
- (gogoproto.moretags) = "yaml:\"value\""
89
- ];
65
+ string block_height = 1 [(gogoproto.jsontag) = "blockHeight", (gogoproto.moretags) = "yaml:\"blockHeight\""];
66
+ string value = 10 [(gogoproto.jsontag) = "value", (gogoproto.moretags) = "yaml:\"value\""];
90
67
  }
91
68
 
92
69
  // QueryChildrenRequest is the vstorage path children query.
93
70
  message QueryChildrenRequest {
94
- string path = 1 [
95
- (gogoproto.jsontag) = "path",
96
- (gogoproto.moretags) = "yaml:\"path\""
97
- ];
71
+ string path = 1 [(gogoproto.jsontag) = "path", (gogoproto.moretags) = "yaml:\"path\""];
98
72
 
99
73
  cosmos.base.query.v1beta1.PageRequest pagination = 2;
100
74
  }
101
75
 
102
76
  // QueryChildrenResponse is the vstorage path children response.
103
77
  message QueryChildrenResponse {
104
- repeated string children = 1 [
105
- (gogoproto.jsontag) = "children",
106
- (gogoproto.moretags) = "yaml:\"children\""
107
- ];
78
+ repeated string children = 1 [(gogoproto.jsontag) = "children", (gogoproto.moretags) = "yaml:\"children\""];
108
79
 
109
80
  cosmos.base.query.v1beta1.PageResponse pagination = 2;
110
81
  }
@@ -7,21 +7,15 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vstorage/types
7
7
 
8
8
  // Data is the vstorage node data.
9
9
  message Data {
10
- option (gogoproto.equal) = false;
10
+ option (gogoproto.equal) = false;
11
11
 
12
- string value = 1 [
13
- (gogoproto.jsontag) = "value",
14
- (gogoproto.moretags) = "yaml:\"value\""
15
- ];
12
+ string value = 1 [(gogoproto.jsontag) = "value", (gogoproto.moretags) = "yaml:\"value\""];
16
13
  }
17
14
 
18
15
  // Children are the immediate names (just one level deep) of subnodes leading to
19
16
  // more data from a given vstorage node.
20
17
  message Children {
21
- option (gogoproto.equal) = false;
18
+ option (gogoproto.equal) = false;
22
19
 
23
- repeated string children = 1 [
24
- (gogoproto.jsontag) = "children",
25
- (gogoproto.moretags) = "yaml:\"children\""
26
- ];
20
+ repeated string children = 1 [(gogoproto.jsontag) = "children", (gogoproto.moretags) = "yaml:\"children\""];
27
21
  }
@@ -7,12 +7,12 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/vtransfer/type
7
7
 
8
8
  // The initial and exported module state.
9
9
  message GenesisState {
10
- option (gogoproto.equal) = false;
10
+ option (gogoproto.equal) = false;
11
11
 
12
- // The list of account addresses that are being watched by the VM.
13
- repeated bytes watched_addresses = 1 [
14
- (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
15
- (gogoproto.jsontag) = "watched_addresses",
16
- (gogoproto.moretags) = "yaml:\"watched_addresses\""
17
- ];
12
+ // The list of account addresses that are being watched by the VM.
13
+ repeated bytes watched_addresses = 1 [
14
+ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
15
+ (gogoproto.jsontag) = "watched_addresses",
16
+ (gogoproto.moretags) = "yaml:\"watched_addresses\""
17
+ ];
18
18
  }
@@ -0,0 +1,8 @@
1
+ version: v1
2
+ plugins:
3
+ - name: gocosmos
4
+ out: ..
5
+ opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types
6
+ - name: grpc-gateway
7
+ out: ..
8
+ opt: logtostderr=true,allow_colon_final_segments=true
@@ -0,0 +1,17 @@
1
+ version: v1
2
+ managed:
3
+ enabled: true
4
+ go_package_prefix:
5
+ default: cosmossdk.io/api
6
+ except:
7
+ - buf.build/googleapis/googleapis
8
+ - buf.build/cosmos/gogo-proto
9
+ - buf.build/cosmos/cosmos-proto
10
+ override:
11
+ plugins:
12
+ - name: go-pulsar
13
+ out: ../api
14
+ opt: paths=source_relative
15
+ - name: go-grpc
16
+ out: ../api
17
+ opt: paths=source_relative
@@ -0,0 +1,5 @@
1
+ version: v1
2
+ plugins:
3
+ - name: swagger
4
+ out: ../tmp-swagger-gen
5
+ opt: logtostderr=true,fqn_for_swagger_name=true,simple_operation_ids=true
package/proto/buf.yaml CHANGED
@@ -1,7 +1,13 @@
1
1
  version: v1
2
+ build:
3
+ excludes:
4
+ - google/protobuf
2
5
  breaking:
3
6
  use:
4
7
  - FILE
8
+ ignore:
9
+ - gogoproto
10
+ - google
5
11
  lint:
6
12
  use:
7
13
  - DEFAULT
@@ -13,3 +19,7 @@ lint:
13
19
  - SERVICE_SUFFIX
14
20
  - PACKAGE_VERSION_SUFFIX
15
21
  - RPC_REQUEST_STANDARD_NAME
22
+ ignore:
23
+ - cosmos_proto
24
+ - gogoproto
25
+ - google
@@ -1,31 +1,24 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- set -eo pipefail
4
-
5
- protoc_gen_gocosmos() {
6
- if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &> /dev/null; then
7
- echo -e "\tPlease run this command from somewhere inside the ibc-go folder."
8
- return 1
9
- fi
10
-
11
- go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2> /dev/null
12
- }
3
+ # How to run manually:
4
+ # docker build --pull --rm -f "contrib/devtools/Dockerfile" -t cosmossdk-proto:latest "contrib/devtools"
5
+ # docker run --rm -v $(pwd):/workspace --workdir /workspace cosmossdk-proto sh ./scripts/protocgen.sh
13
6
 
14
- protoc_gen_gocosmos
7
+ set -eo pipefail
15
8
 
16
- proto_dirs=$(find . -path ./third_party -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
9
+ echo "Generating gogo proto code"
10
+ cd proto
11
+ proto_dirs=$(find . -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
17
12
  for dir in $proto_dirs; do
18
- # NOTE: when migrating to grpc-gateway v2, we will need to remove the
19
- # allow_colon_final_segments=true
20
- # as per https://grpc-ecosystem.github.io/grpc-gateway/docs/development/grpc-gateway_v2_migration_guide/#withlastmatchwins-and-allow_colon_final_segmentstrue-is-now-default-behaviour
21
- protoc \
22
- -I proto \
23
- -I third_party/proto \
24
- --gocosmos_out=plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
25
- --grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
26
- $(find "${dir}" -maxdepth 1 -name '*.proto')
13
+ for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
14
+ echo "Generating gogo proto code for $file"
15
+ buf generate --template buf.gen.gogo.yaml "$file"
16
+ done
27
17
  done
18
+ cd ..
28
19
 
29
20
  # move proto files to the right places
30
21
  cp -r github.com/Agoric/agoric-sdk/golang/cosmos/* ./
31
22
  rm -rf github.com
23
+
24
+ go mod tidy
@@ -0,0 +1,79 @@
1
+ syntax = "proto3";
2
+
3
+ package amino;
4
+
5
+ import "google/protobuf/descriptor.proto";
6
+
7
+ // TODO(fdymylja): once we fully migrate to protov2 the go_package needs to be updated.
8
+ // We need this right now because gogoproto codegen needs to import the extension.
9
+ option go_package = "github.com/cosmos/cosmos-sdk/types/tx/amino";
10
+
11
+ extend google.protobuf.MessageOptions {
12
+ // name is the string used when registering a concrete
13
+ // type into the Amino type registry, via the Amino codec's
14
+ // `RegisterConcrete()` method. This string MUST be at most 39
15
+ // characters long, or else the message will be rejected by the
16
+ // Ledger hardware device.
17
+ string name = 11110001;
18
+
19
+ // encoding describes the encoding format used by Amino for the given
20
+ // message. The field type is chosen to be a string for
21
+ // flexibility, but it should ideally be short and expected to be
22
+ // machine-readable, for example "base64" or "utf8_json". We
23
+ // highly recommend to use underscores for word separation instead of spaces.
24
+ //
25
+ // If left empty, then the Amino encoding is expected to be the same as the
26
+ // Protobuf one.
27
+ //
28
+ // This annotation should not be confused with the `encoding`
29
+ // one which operates on the field level.
30
+ string message_encoding = 11110002;
31
+ }
32
+
33
+ extend google.protobuf.FieldOptions {
34
+ // encoding describes the encoding format used by Amino for
35
+ // the given field. The field type is chosen to be a string for
36
+ // flexibility, but it should ideally be short and expected to be
37
+ // machine-readable, for example "base64" or "utf8_json". We
38
+ // highly recommend to use underscores for word separation instead of spaces.
39
+ //
40
+ // If left empty, then the Amino encoding is expected to be the same as the
41
+ // Protobuf one.
42
+ //
43
+ // This annotation should not be confused with the
44
+ // `message_encoding` one which operates on the message level.
45
+ string encoding = 11110003;
46
+
47
+ // field_name sets a different field name (i.e. key name) in
48
+ // the amino JSON object for the given field.
49
+ //
50
+ // Example:
51
+ //
52
+ // message Foo {
53
+ // string bar = 1 [(amino.field_name) = "baz"];
54
+ // }
55
+ //
56
+ // Then the Amino encoding of Foo will be:
57
+ // `{"baz":"some value"}`
58
+ string field_name = 11110004;
59
+
60
+ // dont_omitempty sets the field in the JSON object even if
61
+ // its value is empty, i.e. equal to the Golang zero value. To learn what
62
+ // the zero values are, see https://go.dev/ref/spec#The_zero_value.
63
+ //
64
+ // Fields default to `omitempty`, which is the default behavior when this
65
+ // annotation is unset. When set to true, then the field value in the
66
+ // JSON object will be set, i.e. not `undefined`.
67
+ //
68
+ // Example:
69
+ //
70
+ // message Foo {
71
+ // string bar = 1;
72
+ // string baz = 2 [(amino.dont_omitempty) = true];
73
+ // }
74
+ //
75
+ // f := Foo{};
76
+ // out := AminoJSONEncoder(&f);
77
+ // out == {"baz":""}
78
+ bool dont_omitempty = 11110005;
79
+ }
@@ -3,6 +3,7 @@ package cosmos.base.v1beta1;
3
3
 
4
4
  import "gogoproto/gogo.proto";
5
5
  import "cosmos_proto/cosmos.proto";
6
+ import "amino/amino.proto";
6
7
 
7
8
  option go_package = "github.com/cosmos/cosmos-sdk/types";
8
9
  option (gogoproto.goproto_stringer_all) = false;
@@ -16,8 +17,12 @@ message Coin {
16
17
  option (gogoproto.equal) = true;
17
18
 
18
19
  string denom = 1;
19
- string amount = 2
20
- [(cosmos_proto.scalar) = "cosmos.Int", (gogoproto.customtype) = "Int", (gogoproto.nullable) = false];
20
+ string amount = 2 [
21
+ (cosmos_proto.scalar) = "cosmos.Int",
22
+ (gogoproto.customtype) = "Int",
23
+ (gogoproto.nullable) = false,
24
+ (amino.dont_omitempty) = true
25
+ ];
21
26
  }
22
27
 
23
28
  // DecCoin defines a token with a denomination and a decimal amount.
@@ -0,0 +1,243 @@
1
+ syntax = "proto3";
2
+
3
+ package cosmos.ics23.v1;
4
+
5
+ option go_package = "github.com/cosmos/ics23/go;ics23";
6
+
7
+ enum HashOp {
8
+ // NO_HASH is the default if no data passed. Note this is an illegal argument some places.
9
+ NO_HASH = 0;
10
+ SHA256 = 1;
11
+ SHA512 = 2;
12
+ KECCAK256 = 3;
13
+ RIPEMD160 = 4;
14
+ BITCOIN = 5; // ripemd160(sha256(x))
15
+ SHA512_256 = 6;
16
+ BLAKE2B_512 = 7;
17
+ BLAKE2S_256 = 8;
18
+ BLAKE3 = 9;
19
+ }
20
+
21
+ /**
22
+ LengthOp defines how to process the key and value of the LeafOp
23
+ to include length information. After encoding the length with the given
24
+ algorithm, the length will be prepended to the key and value bytes.
25
+ (Each one with it's own encoded length)
26
+ */
27
+ enum LengthOp {
28
+ // NO_PREFIX don't include any length info
29
+ NO_PREFIX = 0;
30
+ // VAR_PROTO uses protobuf (and go-amino) varint encoding of the length
31
+ VAR_PROTO = 1;
32
+ // VAR_RLP uses rlp int encoding of the length
33
+ VAR_RLP = 2;
34
+ // FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer
35
+ FIXED32_BIG = 3;
36
+ // FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer
37
+ FIXED32_LITTLE = 4;
38
+ // FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer
39
+ FIXED64_BIG = 5;
40
+ // FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer
41
+ FIXED64_LITTLE = 6;
42
+ // REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output)
43
+ REQUIRE_32_BYTES = 7;
44
+ // REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output)
45
+ REQUIRE_64_BYTES = 8;
46
+ }
47
+
48
+ /**
49
+ ExistenceProof takes a key and a value and a set of steps to perform on it.
50
+ The result of peforming all these steps will provide a "root hash", which can
51
+ be compared to the value in a header.
52
+
53
+ Since it is computationally infeasible to produce a hash collission for any of the used
54
+ cryptographic hash functions, if someone can provide a series of operations to transform
55
+ a given key and value into a root hash that matches some trusted root, these key and values
56
+ must be in the referenced merkle tree.
57
+
58
+ The only possible issue is maliablity in LeafOp, such as providing extra prefix data,
59
+ which should be controlled by a spec. Eg. with lengthOp as NONE,
60
+ prefix = FOO, key = BAR, value = CHOICE
61
+ and
62
+ prefix = F, key = OOBAR, value = CHOICE
63
+ would produce the same value.
64
+
65
+ With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field
66
+ in the ProofSpec is valuable to prevent this mutability. And why all trees should
67
+ length-prefix the data before hashing it.
68
+ */
69
+ message ExistenceProof {
70
+ bytes key = 1;
71
+ bytes value = 2;
72
+ LeafOp leaf = 3;
73
+ repeated InnerOp path = 4;
74
+ }
75
+
76
+ /*
77
+ NonExistenceProof takes a proof of two neighbors, one left of the desired key,
78
+ one right of the desired key. If both proofs are valid AND they are neighbors,
79
+ then there is no valid proof for the given key.
80
+ */
81
+ message NonExistenceProof {
82
+ bytes key = 1; // TODO: remove this as unnecessary??? we prove a range
83
+ ExistenceProof left = 2;
84
+ ExistenceProof right = 3;
85
+ }
86
+
87
+ /*
88
+ CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages
89
+ */
90
+ message CommitmentProof {
91
+ oneof proof {
92
+ ExistenceProof exist = 1;
93
+ NonExistenceProof nonexist = 2;
94
+ BatchProof batch = 3;
95
+ CompressedBatchProof compressed = 4;
96
+ }
97
+ }
98
+
99
+ /**
100
+ LeafOp represents the raw key-value data we wish to prove, and
101
+ must be flexible to represent the internal transformation from
102
+ the original key-value pairs into the basis hash, for many existing
103
+ merkle trees.
104
+
105
+ key and value are passed in. So that the signature of this operation is:
106
+ leafOp(key, value) -> output
107
+
108
+ To process this, first prehash the keys and values if needed (ANY means no hash in this case):
109
+ hkey = prehashKey(key)
110
+ hvalue = prehashValue(value)
111
+
112
+ Then combine the bytes, and hash it
113
+ output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue)
114
+ */
115
+ message LeafOp {
116
+ HashOp hash = 1;
117
+ HashOp prehash_key = 2;
118
+ HashOp prehash_value = 3;
119
+ LengthOp length = 4;
120
+ // prefix is a fixed bytes that may optionally be included at the beginning to differentiate
121
+ // a leaf node from an inner node.
122
+ bytes prefix = 5;
123
+ }
124
+
125
+ /**
126
+ InnerOp represents a merkle-proof step that is not a leaf.
127
+ It represents concatenating two children and hashing them to provide the next result.
128
+
129
+ The result of the previous step is passed in, so the signature of this op is:
130
+ innerOp(child) -> output
131
+
132
+ The result of applying InnerOp should be:
133
+ output = op.hash(op.prefix || child || op.suffix)
134
+
135
+ where the || operator is concatenation of binary data,
136
+ and child is the result of hashing all the tree below this step.
137
+
138
+ Any special data, like prepending child with the length, or prepending the entire operation with
139
+ some value to differentiate from leaf nodes, should be included in prefix and suffix.
140
+ If either of prefix or suffix is empty, we just treat it as an empty string
141
+ */
142
+ message InnerOp {
143
+ HashOp hash = 1;
144
+ bytes prefix = 2;
145
+ bytes suffix = 3;
146
+ }
147
+
148
+ /**
149
+ ProofSpec defines what the expected parameters are for a given proof type.
150
+ This can be stored in the client and used to validate any incoming proofs.
151
+
152
+ verify(ProofSpec, Proof) -> Proof | Error
153
+
154
+ As demonstrated in tests, if we don't fix the algorithm used to calculate the
155
+ LeafHash for a given tree, there are many possible key-value pairs that can
156
+ generate a given hash (by interpretting the preimage differently).
157
+ We need this for proper security, requires client knows a priori what
158
+ tree format server uses. But not in code, rather a configuration object.
159
+ */
160
+ message ProofSpec {
161
+ // any field in the ExistenceProof must be the same as in this spec.
162
+ // except Prefix, which is just the first bytes of prefix (spec can be longer)
163
+ LeafOp leaf_spec = 1;
164
+ InnerSpec inner_spec = 2;
165
+ // max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries)
166
+ // the max_depth is interpreted as 128 if set to 0
167
+ int32 max_depth = 3;
168
+ // min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries)
169
+ int32 min_depth = 4;
170
+ // prehash_key_before_comparison is a flag that indicates whether to use the
171
+ // prehash_key specified by LeafOp to compare lexical ordering of keys for
172
+ // non-existence proofs.
173
+ bool prehash_key_before_comparison = 5;
174
+ }
175
+
176
+ /*
177
+ InnerSpec contains all store-specific structure info to determine if two proofs from a
178
+ given store are neighbors.
179
+
180
+ This enables:
181
+
182
+ isLeftMost(spec: InnerSpec, op: InnerOp)
183
+ isRightMost(spec: InnerSpec, op: InnerOp)
184
+ isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp)
185
+ */
186
+ message InnerSpec {
187
+ // Child order is the ordering of the children node, must count from 0
188
+ // iavl tree is [0, 1] (left then right)
189
+ // merk is [0, 2, 1] (left, right, here)
190
+ repeated int32 child_order = 1;
191
+ int32 child_size = 2;
192
+ int32 min_prefix_length = 3;
193
+ // the max prefix length must be less than the minimum prefix length + child size
194
+ int32 max_prefix_length = 4;
195
+ // empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0)
196
+ bytes empty_child = 5;
197
+ // hash is the algorithm that must be used for each InnerOp
198
+ HashOp hash = 6;
199
+ }
200
+
201
+ /*
202
+ BatchProof is a group of multiple proof types than can be compressed
203
+ */
204
+ message BatchProof {
205
+ repeated BatchEntry entries = 1;
206
+ }
207
+
208
+ // Use BatchEntry not CommitmentProof, to avoid recursion
209
+ message BatchEntry {
210
+ oneof proof {
211
+ ExistenceProof exist = 1;
212
+ NonExistenceProof nonexist = 2;
213
+ }
214
+ }
215
+
216
+ /****** all items here are compressed forms *******/
217
+
218
+ message CompressedBatchProof {
219
+ repeated CompressedBatchEntry entries = 1;
220
+ repeated InnerOp lookup_inners = 2;
221
+ }
222
+
223
+ // Use BatchEntry not CommitmentProof, to avoid recursion
224
+ message CompressedBatchEntry {
225
+ oneof proof {
226
+ CompressedExistenceProof exist = 1;
227
+ CompressedNonExistenceProof nonexist = 2;
228
+ }
229
+ }
230
+
231
+ message CompressedExistenceProof {
232
+ bytes key = 1;
233
+ bytes value = 2;
234
+ LeafOp leaf = 3;
235
+ // these are indexes into the lookup_inners table in CompressedBatchProof
236
+ repeated int32 path = 4;
237
+ }
238
+
239
+ message CompressedNonExistenceProof {
240
+ bytes key = 1; // TODO: remove this as unnecessary??? we prove a range
241
+ CompressedExistenceProof left = 2;
242
+ CompressedExistenceProof right = 3;
243
+ }