@agoric/cosmos 0.34.2-dev-1b8f70d.0.1b8f70d → 0.34.2-dev-27d1c7b.0.27d1c7b

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/git-revision.txt CHANGED
@@ -1 +1 @@
1
- 1b8f70d
1
+ 27d1c7b
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agoric/cosmos",
3
- "version": "0.34.2-dev-1b8f70d.0.1b8f70d",
3
+ "version": "0.34.2-dev-27d1c7b.0.27d1c7b",
4
4
  "description": "Connect JS to the Cosmos blockchain SDK",
5
5
  "parsers": {
6
6
  "js": "mjs"
@@ -41,5 +41,5 @@
41
41
  "typeCoverage": {
42
42
  "atLeast": 0
43
43
  },
44
- "gitHead": "1b8f70d277abe7b3457127f27236f23d4634d789"
44
+ "gitHead": "27d1c7b3d3d340835c9e6f778c053e9be341bf9a"
45
45
  }
@@ -5,6 +5,7 @@ import "amino/amino.proto";
5
5
  import "cosmos/msg/v1/msg.proto";
6
6
  import "cosmos_proto/cosmos.proto";
7
7
  import "gogoproto/gogo.proto";
8
+ import "agoric/swingset/swingset.proto";
8
9
 
9
10
  option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types";
10
11
 
@@ -12,6 +13,8 @@ option go_package = "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types
12
13
  service Msg {
13
14
  // Install a JavaScript sources bundle on the chain's SwingSet controller.
14
15
  rpc InstallBundle(MsgInstallBundle) returns (MsgInstallBundleResponse);
16
+ // Send a chunk of a bundle (or other artifact) to tolerate RPC message size limits.
17
+ rpc SendChunk(MsgSendChunk) returns (MsgSendChunkResponse);
15
18
  // Send inbound messages.
16
19
  rpc DeliverInbound(MsgDeliverInbound) returns (MsgDeliverInboundResponse);
17
20
  // Perform a low-privilege wallet action.
@@ -127,6 +130,12 @@ message MsgProvision {
127
130
  message MsgProvisionResponse {}
128
131
 
129
132
  // MsgInstallBundle carries a signed bundle to SwingSet.
133
+ // The fields `bundle`, `compressed_bundle`, and `chunked_artifact` are mutually
134
+ // exclusive, and exactly one must be present based on what is being submitted:
135
+ // * `bundle` for a complete and uncompressed bundle
136
+ // * `compressed_bundle` for a complete and compressed bundle
137
+ // * `chunked_artifact` for a manifest of chunks to be submitted in subsequent
138
+ // messages.
130
139
  message MsgInstallBundle {
131
140
  // Until agoric-upgrade-22 this message didn't have an amino name
132
141
  // but no clients actually used amino encoding
@@ -140,7 +149,6 @@ message MsgInstallBundle {
140
149
  (gogoproto.jsontag) = "submitter",
141
150
  (gogoproto.moretags) = "yaml:\"submitter\""
142
151
  ];
143
- // Either bundle or compressed_bundle will be set.
144
152
  // Default compression algorithm is gzip.
145
153
  bytes compressed_bundle = 3 [
146
154
  (amino.dont_omitempty) = true,
@@ -148,18 +156,21 @@ message MsgInstallBundle {
148
156
  (gogoproto.jsontag) = "compressedBundle",
149
157
  (gogoproto.moretags) = "yaml:\"compressedBundle\""
150
158
  ];
151
- // Size in bytes of uncompression of compressed_bundle.
159
+ // Total size in bytes of the bundle artifact, before compression and after
160
+ // decompression.
152
161
  int64 uncompressed_size = 4 [
153
162
  (amino.dont_omitempty) = true,
154
163
  (amino.field_name) = "uncompressedSize",
155
164
  (gogoproto.jsontag) = "uncompressedSize"
156
165
  ];
166
+ // Declaration of a chunked bundle.
167
+ ChunkedArtifact chunked_artifact = 5 [
168
+ (amino.field_name) = "chunkedArtifact",
169
+ (gogoproto.jsontag) = "chunkedArtifact,omitempty",
170
+ (gogoproto.moretags) = "yaml:\"chunkedArtifact\""
171
+ ];
157
172
  }
158
173
 
159
- // MsgInstallBundleResponse is an empty acknowledgement that an install bundle
160
- // message has been queued for the SwingSet kernel's consideration.
161
- message MsgInstallBundleResponse {}
162
-
163
174
  // MsgCoreEval defines an SDK message for a core eval.
164
175
  message MsgCoreEval {
165
176
  option (cosmos.msg.v1.signer) = "authority";
@@ -181,3 +192,61 @@ message MsgCoreEvalResponse {
181
192
  // The result of the core eval.
182
193
  string result = 1 [(gogoproto.moretags) = "yaml:\"result\""];
183
194
  }
195
+
196
+ // MsgInstallBundleResponse is either an empty acknowledgement that a bundle
197
+ // installation message has been queued for the SwingSet kernel's
198
+ // consideration, or (for MsgInstallBundle requests that have a chunked artifact
199
+ // manifest instead of a compressed or uncompressed bundle) a container for the
200
+ // chunked artifact identifier to be included in subsequent MsgSendChunk
201
+ // messages.
202
+ message MsgInstallBundleResponse {
203
+ // The assigned identifier for a chunked artifact, if the caller is expected
204
+ // to call back with MsgSendChunk messages.
205
+ uint64 chunked_artifact_id = 1 [
206
+ (amino.field_name) = "chunkedArtifactId",
207
+ (gogoproto.jsontag) = "chunkedArtifactId",
208
+ (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""
209
+ ];
210
+ }
211
+
212
+ // MsgSendChunk carries a chunk of an artifact through RPC to the chain.
213
+ // Individual chunks are addressed by the chunked artifact identifier and
214
+ // the zero-based index of the chunk among all chunks as mentioned in the
215
+ // manifest provided to MsgInstallBundle.
216
+ message MsgSendChunk {
217
+ uint64 chunked_artifact_id = 1 [
218
+ (amino.field_name) = "chunkedArtifactId",
219
+ (gogoproto.jsontag) = "chunkedArtifactId",
220
+ (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""
221
+ ];
222
+ bytes submitter = 2 [
223
+ (amino.encoding) = "legacy_address",
224
+ (amino.field_name) = "submitter",
225
+ (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress",
226
+ (gogoproto.jsontag) = "submitter",
227
+ (gogoproto.moretags) = "yaml:\"submitter\""
228
+ ];
229
+ uint64 chunk_index = 3 [
230
+ (amino.field_name) = "chunkIndex",
231
+ (gogoproto.jsontag) = "chunkIndex",
232
+ (gogoproto.moretags) = "yaml:\"chunkIndex\""
233
+ ];
234
+ bytes chunk_data = 4 [
235
+ (amino.field_name) = "chunkData",
236
+ (gogoproto.jsontag) = "chunkData",
237
+ (gogoproto.moretags) = "yaml:\"chunkData\""
238
+ ];
239
+ }
240
+
241
+ // MsgSendChunkResponse is an acknowledgement that a chunk has been received by
242
+ // the chain.
243
+ message MsgSendChunkResponse {
244
+ uint64 chunked_artifact_id = 1 [
245
+ (amino.field_name) = "chunkedArtifactId",
246
+ (gogoproto.jsontag) = "chunkedArtifactId",
247
+ (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""
248
+ ];
249
+ // The current state of the chunk.
250
+ ChunkInfo chunk = 2
251
+ [(amino.field_name) = "chunk", (gogoproto.jsontag) = "chunk", (gogoproto.moretags) = "yaml:\"chunk\""];
252
+ }
@@ -23,6 +23,11 @@ service Query {
23
23
  rpc Mailbox(QueryMailboxRequest) returns (QueryMailboxResponse) {
24
24
  option (google.api.http).get = "/agoric/swingset/mailbox/{peer}";
25
25
  }
26
+
27
+ // Return the state of a pending installation.
28
+ rpc ChunkedArtifactStatus(QueryChunkedArtifactStatusRequest) returns (QueryChunkedArtifactStatusResponse) {
29
+ option (google.api.http).get = "/agoric/swingset/chunked-artifact-status/{chunked_artifact_id}";
30
+ }
26
31
  }
27
32
 
28
33
  // QueryParamsRequest is the request type for the Query/Params RPC method.
@@ -61,3 +66,24 @@ message QueryMailboxRequest {
61
66
  message QueryMailboxResponse {
62
67
  string value = 1 [(gogoproto.jsontag) = "value", (gogoproto.moretags) = "yaml:\"value\""];
63
68
  }
69
+
70
+ // QueryChunkedArtifactStatusRequest is the request type for the Query/ChunkedArtifact RPC method.
71
+ message QueryChunkedArtifactStatusRequest {
72
+ uint64 chunked_artifact_id = 1
73
+ [(gogoproto.jsontag) = "chunkedArtifactId", (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""];
74
+ }
75
+
76
+ // QueryChunkedArtifactStatusResponse is the response type for the Query/ChunkedArtifact RPC method.
77
+ message QueryChunkedArtifactStatusResponse {
78
+ uint64 chunked_artifact_id = 1
79
+ [(gogoproto.jsontag) = "chunkedArtifactId", (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""];
80
+
81
+ ChunkedArtifact chunked_artifact = 2
82
+ [(gogoproto.jsontag) = "chunkedArtifact", (gogoproto.moretags) = "yaml:\"chunkedArtifact\""];
83
+
84
+ // Start time in UNIX epoch seconds.
85
+ int64 start_time_unix = 3 [(gogoproto.jsontag) = "startTimeUnix", (gogoproto.moretags) = "yaml:\"startTimeUnix\""];
86
+
87
+ int64 start_block_height = 4
88
+ [(gogoproto.jsontag) = "startBlockHeight", (gogoproto.moretags) = "yaml:\"startBlockHeight\""];
89
+ }
@@ -89,6 +89,21 @@ message Params {
89
89
  // nodes must all serialize and deserialize the existing order without
90
90
  // permuting it.
91
91
  repeated UintMapEntry vat_cleanup_budget = 6 [(gogoproto.nullable) = false];
92
+
93
+ // The maximum number of blocks that an async installation can use. -1 is
94
+ // unlimited.
95
+ int64 installation_deadline_blocks = 7;
96
+
97
+ // The maximum number of seconds that an async installation can use. -1 is
98
+ // unlimited.
99
+ int64 installation_deadline_seconds = 8;
100
+
101
+ // The maximum size of a bundle (0 implies default 10000000 bytes). This
102
+ // limit is exclusive.
103
+ int64 bundle_uncompressed_size_limit_bytes = 9;
104
+
105
+ // The maximum size of a bundle or artifact chunk (0 implies default 490000 bytes)
106
+ int64 chunk_size_limit_bytes = 10;
92
107
  }
93
108
 
94
109
  // The current state of the module.
@@ -96,6 +111,18 @@ message State {
96
111
  // The allowed number of items to add to queues, as determined by SwingSet.
97
112
  // Transactions which attempt to enqueue more should be rejected.
98
113
  repeated QueueSize queue_allowed = 1 [(gogoproto.nullable) = false];
114
+
115
+ // Doubly-linked list in order of ascending start block and time.
116
+ uint64 first_chunked_artifact_id = 2
117
+ [(gogoproto.jsontag) = "first_chunked_artifact_id", (gogoproto.moretags) = "yaml:\"first_chunked_artifact_id\""];
118
+
119
+ // The last chunked artifact id that has not expired nor completed.
120
+ uint64 last_chunked_artifact_id = 3
121
+ [(gogoproto.jsontag) = "last_chunked_artifact_id", (gogoproto.moretags) = "yaml:\"last_chunked_artifact_id\""];
122
+
123
+ // The next monotonically increasing chunked artifact id to allocate.
124
+ uint64 next_chunked_artifact_id = 4
125
+ [(gogoproto.jsontag) = "next_chunked_artifact_id", (gogoproto.moretags) = "yaml:\"next_chunked_artifact_id\""];
99
126
  }
100
127
 
101
128
  // Map element of a string key to a Nat bean count.
@@ -167,3 +194,71 @@ message SwingStoreArtifact {
167
194
 
168
195
  bytes data = 2 [(gogoproto.jsontag) = "data", (gogoproto.moretags) = "yaml:\"data\""];
169
196
  }
197
+
198
+ // ChunkedArtifact is the manifest for an artifact that is submitted across
199
+ // multiple transactions, in chunks, as when using InstallBundle to submit
200
+ // chunks.
201
+ message ChunkedArtifact {
202
+ // The SHA-512 hash of the entire artifact's contents.
203
+ string sha512 = 1 [(gogoproto.jsontag) = "sha512", (gogoproto.moretags) = "yaml:\"sha512\""];
204
+
205
+ // The size of the final artifact in bytes.
206
+ uint64 size_bytes = 2 [(gogoproto.jsontag) = "size_bytes", (gogoproto.moretags) = "yaml:\"size_bytes\""];
207
+
208
+ // Information about the chunks that will be concatenated to form this
209
+ // artifact.
210
+ repeated ChunkInfo chunks = 3 [(gogoproto.jsontag) = "chunks", (gogoproto.moretags) = "yaml:\"chunks\""];
211
+ }
212
+
213
+ // Current state of this chunk.
214
+ enum ChunkState {
215
+ // Unknown state.
216
+ CHUNK_STATE_UNSPECIFIED = 0;
217
+
218
+ // The chunk is still in-flight.
219
+ CHUNK_STATE_IN_FLIGHT = 1;
220
+
221
+ // The chunk has been received.
222
+ CHUNK_STATE_RECEIVED = 2;
223
+
224
+ // The chunk has been processed.
225
+ CHUNK_STATE_PROCESSED = 3;
226
+ };
227
+
228
+ // Information about a chunk of an artifact.
229
+ message ChunkInfo {
230
+ // The SHA-512 hash of the chunk contents.
231
+ string sha512 = 1 [(gogoproto.jsontag) = "sha512", (gogoproto.moretags) = "yaml:\"sha512\""];
232
+
233
+ // The chunk size in bytes.
234
+ uint64 size_bytes = 2 [(gogoproto.jsontag) = "size_bytes", (gogoproto.moretags) = "yaml:\"size_bytes\""];
235
+
236
+ // The current state of the chunk.
237
+ ChunkState state = 3 [(gogoproto.jsontag) = "state", (gogoproto.moretags) = "yaml:\"state\""];
238
+ }
239
+
240
+ // A node in a doubly-linked-list of chunked artifacts, as used for chunked
241
+ // bundle installation, in order of ascending block time.
242
+ // This list is not circular and has no sentinel head node; the start and end
243
+ // are indicated by prev_id/next_id being 0.
244
+ // The keeper uses this to expediently expire stale incomplete artifacts.
245
+ message ChunkedArtifactNode {
246
+ // The id of the pending bundle installation.
247
+ uint64 chunked_artifact_id = 1
248
+ [(gogoproto.jsontag) = "chunkedArtifactId", (gogoproto.moretags) = "yaml:\"chunkedArtifactId\""];
249
+
250
+ // The ID of the next chunked artifact in the list.
251
+ // A value of 0 indicates the end of the list.
252
+ uint64 next_id = 2 [(gogoproto.jsontag) = "nextId", (gogoproto.moretags) = "yaml:\"nextId\""];
253
+
254
+ // The ID of the previous chunked artifact in the list.
255
+ // A value of 0 indicates the start of the list.
256
+ uint64 prev_id = 3 [(gogoproto.jsontag) = "prevId", (gogoproto.moretags) = "yaml:\"prevId\""];
257
+
258
+ // The time at which the pending installation began, in UNIX epoch seconds.
259
+ int64 start_time_unix = 4 [(gogoproto.jsontag) = "startTimeUnix", (gogoproto.moretags) = "yaml:\"startTimeUnix\""];
260
+
261
+ // The block at which the pending installation began.
262
+ int64 start_block_height = 5
263
+ [(gogoproto.jsontag) = "startBlockHeight", (gogoproto.moretags) = "yaml:\"startBlockHeight\""];
264
+ }
@@ -66,6 +66,11 @@ func EndBlock(ctx sdk.Context, keeper Keeper) ([]abci.ValidatorUpdate, error) {
66
66
  panic(err)
67
67
  }
68
68
 
69
+ // Remove expired bundle installs.
70
+ if err := keeper.PruneExpiredBundleInstalls(ctx); err != nil {
71
+ return nil, err
72
+ }
73
+
69
74
  // Save our EndBlock status.
70
75
  endBlockHeight = ctx.BlockHeight()
71
76
  endBlockTime = ctx.BlockTime().Unix()
@@ -0,0 +1,168 @@
1
+ package keeper_test
2
+
3
+ import (
4
+ "testing"
5
+
6
+ "cosmossdk.io/log"
7
+ "cosmossdk.io/store"
8
+ storemetrics "cosmossdk.io/store/metrics"
9
+ storetypes "cosmossdk.io/store/types"
10
+ cmtproto "github.com/cometbft/cometbft/proto/tendermint/types"
11
+ cmttime "github.com/cometbft/cometbft/types/time"
12
+ dbm "github.com/cosmos/cosmos-db"
13
+ "github.com/cosmos/cosmos-sdk/codec"
14
+ "github.com/cosmos/cosmos-sdk/runtime"
15
+ sdk "github.com/cosmos/cosmos-sdk/types"
16
+ moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
17
+ paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
18
+
19
+ "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/keeper"
20
+ swingsettypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/swingset/types"
21
+ vbanktypes "github.com/Agoric/agoric-sdk/golang/cosmos/x/vbank/types"
22
+ )
23
+
24
+ type keeperTestEnv struct {
25
+ ctx sdk.Context
26
+ keeper keeper.Keeper
27
+ }
28
+
29
+ func setupKeeperTestEnv(t *testing.T) *keeperTestEnv {
30
+ t.Helper()
31
+
32
+ encCfg := moduletestutil.MakeTestEncodingConfig()
33
+ key := storetypes.NewKVStoreKey(swingsettypes.StoreKey)
34
+ paramsKey := storetypes.NewKVStoreKey("params")
35
+ paramsTKey := storetypes.NewTransientStoreKey("transient_params")
36
+
37
+ db := dbm.NewMemDB()
38
+ logger := log.NewNopLogger()
39
+ ms := store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics())
40
+ ms.MountStoreWithDB(key, storetypes.StoreTypeIAVL, db)
41
+ ms.MountStoreWithDB(paramsKey, storetypes.StoreTypeIAVL, db)
42
+ ms.MountStoreWithDB(paramsTKey, storetypes.StoreTypeTransient, db)
43
+ if err := ms.LoadLatestVersion(); err != nil {
44
+ t.Fatalf("failed to load multi-store: %v", err)
45
+ }
46
+
47
+ ctx := sdk.NewContext(ms, cmtproto.Header{Time: cmttime.Now()}, false, logger)
48
+
49
+ paramsKeeper := paramskeeper.NewKeeper(encCfg.Codec, codec.NewLegacyAmino(), paramsKey, paramsTKey)
50
+ paramsKeeper.Subspace(swingsettypes.ModuleName)
51
+ paramsSubspace, _ := paramsKeeper.GetSubspace(swingsettypes.ModuleName)
52
+
53
+ callToController := func(ctx sdk.Context, jsonRequest string) (string, error) {
54
+ return "", nil
55
+ }
56
+
57
+ k := keeper.NewKeeper(
58
+ encCfg.Codec,
59
+ runtime.NewKVStoreService(key),
60
+ paramsSubspace,
61
+ nil,
62
+ nil,
63
+ nil,
64
+ vbanktypes.ReservePoolName,
65
+ authority,
66
+ callToController,
67
+ )
68
+ k.SetParams(ctx, swingsettypes.DefaultParams())
69
+ k.SetState(ctx, swingsettypes.State{})
70
+
71
+ return &keeperTestEnv{ctx: ctx, keeper: k}
72
+ }
73
+
74
+ func TestChunkedArtifactIdMonotonicAfterRemoval(t *testing.T) {
75
+ env := setupKeeperTestEnv(t)
76
+
77
+ first, err := env.keeper.AddPendingBundleInstall(env.ctx, &swingsettypes.MsgInstallBundle{Submitter: submitAddr})
78
+ if err != nil {
79
+ t.Fatalf("AddPendingBundleInstall failed: %v", err)
80
+ }
81
+ if first == 0 {
82
+ t.Fatalf("allocated chunked artifact id must not be 0")
83
+ }
84
+ if err := env.keeper.SetPendingBundleInstall(env.ctx, first, nil); err != nil {
85
+ t.Fatalf("SetPendingBundleInstall failed: %v", err)
86
+ }
87
+ second, err := env.keeper.AddPendingBundleInstall(env.ctx, &swingsettypes.MsgInstallBundle{Submitter: submitAddr})
88
+ if err != nil {
89
+ t.Fatalf("AddPendingBundleInstall failed: %v", err)
90
+ }
91
+
92
+ if second != first+1 {
93
+ t.Fatalf("expected chunked artifact id to be monotonic after removal: got %d, want %d", second, first+1)
94
+ }
95
+ }
96
+
97
+ func TestAddPendingBundleInstallLinksList(t *testing.T) {
98
+ env := setupKeeperTestEnv(t)
99
+
100
+ first, err := env.keeper.AddPendingBundleInstall(env.ctx, &swingsettypes.MsgInstallBundle{Submitter: submitAddr})
101
+ if err != nil {
102
+ t.Fatalf("AddPendingBundleInstall failed: %v", err)
103
+ }
104
+ second, err := env.keeper.AddPendingBundleInstall(env.ctx, &swingsettypes.MsgInstallBundle{Submitter: submitAddr})
105
+ if err != nil {
106
+ t.Fatalf("AddPendingBundleInstall failed: %v", err)
107
+ }
108
+
109
+ state := env.keeper.GetState(env.ctx)
110
+ if state.FirstChunkedArtifactId != first {
111
+ t.Fatalf("expected first chunked artifact id %d, got %d", first, state.FirstChunkedArtifactId)
112
+ }
113
+ if state.LastChunkedArtifactId != second {
114
+ t.Fatalf("expected last chunked artifact id %d, got %d", second, state.LastChunkedArtifactId)
115
+ }
116
+
117
+ firstNode := env.keeper.GetChunkedArtifactNode(env.ctx, first)
118
+ if firstNode == nil {
119
+ t.Fatalf("expected node for chunked artifact id %d", first)
120
+ }
121
+ secondNode := env.keeper.GetChunkedArtifactNode(env.ctx, second)
122
+ if secondNode == nil {
123
+ t.Fatalf("expected node for chunked artifact id %d", second)
124
+ }
125
+ if firstNode.PrevId != 0 {
126
+ t.Fatalf("expected first node prev id %d, got %d", 0, firstNode.PrevId)
127
+ }
128
+ if firstNode.NextId != second {
129
+ t.Fatalf("expected first node next id %d, got %d", second, firstNode.NextId)
130
+ }
131
+ if secondNode.PrevId != first {
132
+ t.Fatalf("expected second node prev id %d, got %d", first, secondNode.PrevId)
133
+ }
134
+ if secondNode.NextId != 0 {
135
+ t.Fatalf("expected second node next id %d, got %d", 0, secondNode.PrevId)
136
+ }
137
+ }
138
+
139
+ func TestPruneExpiredBundleInstallsClearsLastWhenEmpty(t *testing.T) {
140
+ env := setupKeeperTestEnv(t)
141
+
142
+ params := env.keeper.GetParams(env.ctx)
143
+ params.InstallationDeadlineSeconds = 0
144
+ params.InstallationDeadlineBlocks = 0
145
+ env.keeper.SetParams(env.ctx, params)
146
+
147
+ chunkedArtifactId, err := env.keeper.AddPendingBundleInstall(env.ctx, &swingsettypes.MsgInstallBundle{Submitter: submitAddr})
148
+ if err != nil {
149
+ t.Fatalf("AddPendingBundleInstall failed: %v", err)
150
+ }
151
+
152
+ state := env.keeper.GetState(env.ctx)
153
+ state.FirstChunkedArtifactId = chunkedArtifactId
154
+ state.LastChunkedArtifactId = chunkedArtifactId
155
+ env.keeper.SetState(env.ctx, state)
156
+
157
+ if err := env.keeper.PruneExpiredBundleInstalls(env.ctx); err != nil {
158
+ t.Fatalf("PruneExpiredBundleInstalls failed: %v", err)
159
+ }
160
+
161
+ state = env.keeper.GetState(env.ctx)
162
+ if state.FirstChunkedArtifactId != 0 {
163
+ t.Fatalf("expected first chunked artifact id to be cleared, got %d", state.FirstChunkedArtifactId)
164
+ }
165
+ if state.LastChunkedArtifactId != 0 {
166
+ t.Fatalf("expected last chunked artifact id to be cleared, got %d", state.LastChunkedArtifactId)
167
+ }
168
+ }
@@ -61,3 +61,27 @@ func (k Querier) Mailbox(c context.Context, req *types.QueryMailboxRequest) (*ty
61
61
  Value: value,
62
62
  }, nil
63
63
  }
64
+
65
+ func (k Querier) ChunkedArtifactStatus(c context.Context, req *types.QueryChunkedArtifactStatusRequest) (*types.QueryChunkedArtifactStatusResponse, error) {
66
+ if req == nil {
67
+ return nil, status.Error(codes.InvalidArgument, "empty request")
68
+ }
69
+ ctx := sdk.UnwrapSDKContext(c)
70
+
71
+ msg := k.GetPendingBundleInstall(ctx, req.ChunkedArtifactId)
72
+ if msg == nil {
73
+ return nil, status.Error(codes.NotFound, "pending chunked artifact not found")
74
+ }
75
+
76
+ can := k.GetChunkedArtifactNode(ctx, req.ChunkedArtifactId)
77
+ if can == nil {
78
+ return nil, status.Error(codes.NotFound, "pending chunked artifact node not found")
79
+ }
80
+
81
+ return &types.QueryChunkedArtifactStatusResponse{
82
+ ChunkedArtifactId: req.ChunkedArtifactId,
83
+ ChunkedArtifact: msg.ChunkedArtifact,
84
+ StartTimeUnix: can.StartTimeUnix,
85
+ StartBlockHeight: can.StartBlockHeight,
86
+ }, nil
87
+ }