Skip to content

Commit 0d78c52

Browse files
authored
Merge pull request #1071 from oasisprotocol/ptrus/feature/rofl-instance-metadata
rofl_instances: Support rofl instance metadata
2 parents 04e4960 + 83a0b59 commit 0d78c52

File tree

8 files changed

+22
-2
lines changed

8 files changed

+22
-2
lines changed

.changelog/1071.feature.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rofl_instances: Support rofl instance metadata

analyzer/queries/queries.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,9 +1360,9 @@ var (
13601360
WHERE runtime = $1::runtime AND id = $2
13611361
)
13621362
1363-
INSERT INTO chain.rofl_instances (runtime, app_id, rak, endorsing_node_id, endorsing_entity_id, rek, expiration_epoch, extra_keys, registration_round, last_processed_round)
1363+
INSERT INTO chain.rofl_instances (runtime, app_id, rak, endorsing_node_id, endorsing_entity_id, rek, expiration_epoch, metadata, extra_keys, registration_round, last_processed_round)
13641364
SELECT
1365-
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10
1365+
$1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
13661366
FROM
13671367
check_app
13681368
ON CONFLICT (runtime, app_id, rak) DO UPDATE
@@ -1371,6 +1371,7 @@ var (
13711371
endorsing_entity_id = excluded.endorsing_entity_id,
13721372
rek = excluded.rek,
13731373
expiration_epoch = excluded.expiration_epoch,
1374+
metadata = excluded.metadata,
13741375
extra_keys = excluded.extra_keys,
13751376
registration_round = LEAST(excluded.registration_round, chain.rofl_instances.registration_round),
13761377
last_processed_round = COALESCE(chain.rofl_instances.last_processed_round, excluded.last_processed_round)`

analyzer/rofl/rofl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ func (p *processor) queueRoflAppInstancesRefresh(ctx context.Context, batch *sto
172172
entityID,
173173
rek,
174174
instance.Expiration,
175+
instance.Metadata,
175176
extraKeys,
176177
// In case the ROFL analyzer would be lagging behind, this round is not necessary the registration round,
177178
// since there could have been more events in the meantime. This means we might miss some early instance

api/spec/v1.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4005,6 +4005,9 @@ components:
40054005
type: integer
40064006
format: uint64
40074007
description: The epoch at which the instance expires.
4008+
metadata:
4009+
type: object
4010+
description: Arbitrary metadata key-value pairs, assigned by the application.
40084011
extra_keys:
40094012
type: array
40104013
items:

storage/client/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,7 @@ func (c *StorageClient) RuntimeRoflAppInstances(ctx context.Context, runtime com
26582658
&instance.EndorsingEntityId,
26592659
&instance.Rek,
26602660
&instance.ExpirationEpoch,
2661+
&instance.Metadata,
26612662
&instance.ExtraKeys,
26622663
); err != nil {
26632664
return nil, wrapError(err)

storage/client/queries/queries.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ const (
987987
endorsing_entity_id,
988988
rek,
989989
expiration_epoch,
990+
metadata,
990991
extra_keys
991992
FROM chain.rofl_instances
992993
WHERE

storage/migrations/19_runtime_rofl.up.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ CREATE TABLE chain.rofl_instances
4646
expiration_epoch UINT63 NOT NULL,
4747
extra_keys TEXT[],
4848

49+
-- metadata JSONB, -- Added in 42_runtime_rofl_instances_metadata.up.sql.
50+
4951
-- Fields for rofl instance transactions analyzer progress tracking.
5052
registration_round UINT63 NOT NULL,
5153
last_processed_round UINT63 NOT NULL
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
BEGIN;
2+
3+
ALTER TABLE chain.rofl_instances ADD COLUMN metadata JSONB;
4+
5+
-- Schedule for refresh all active rofl apps.
6+
UPDATE chain.rofl_apps
7+
SET last_processed_round = NULL
8+
WHERE removed = FALSE;
9+
10+
COMMIT;

0 commit comments

Comments
 (0)