-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.dbm
352 lines (332 loc) · 11.7 KB
/
db.dbm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?xml version="1.0" encoding="UTF-8"?>
<!--
CAUTION: Do not modify this file unless you know what you are doing.
Unexpected results may occur if the code is changed deliberately.
-->
<dbmodel pgmodeler-ver="1.1.6" use-changelog="false" max-obj-count="18"
last-position="0,0" last-zoom="1" scene-rect="0,0,1570.8,1076.8"
default-schema="public" default-owner="postgres"
layers="Default layer"
active-layers="0"
layer-name-colors="#000000"
layer-rect-colors="#b4b4b4"
show-layer-names="false" show-layer-rects="false">
<role name="plutus-admin"
superuser="true"
createdb="true"
createrole="true"
login="true">
</role>
<role name="plutus-indexer"
login="true">
</role>
<role name="plutus-reader"
login="true">
</role>
<database name="mainnet_plutus_events" is-template="false" allow-conns="true">
</database>
<schema name="public" layers="0" fill-color="#e1e1e1" name-color="#000000" sql-disabled="true">
</schema>
<table name="script_evaluation_events" layers="0" collapse-mode="2" max-obj-count="14" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="940" y="60"/>
<column name="pk" not-null="true"
identity-type="ALWAYS">
<type name="bigint" length="0"/>
</column>
<column name="slot" not-null="true">
<type name="bigint" length="0"/>
<comment> <![CDATA[Absolute Slot Number]]> </comment>
</column>
<column name="block" not-null="true">
<type name="bigint" length="0"/>
<comment> <![CDATA[Block Height]]> </comment>
</column>
<column name="major_protocol_version" not-null="true">
<type name="smallint" length="0"/>
</column>
<column name="evaluated_successfully" not-null="true">
<type name="bool" length="0"/>
</column>
<column name="exec_budget_cpu" not-null="true">
<type name="bigint" length="0"/>
</column>
<column name="exec_budget_mem" not-null="true">
<type name="bigint" length="0"/>
</column>
<column name="script_hash" not-null="true">
<type name="bytea" length="0"/>
</column>
<column name="datum">
<type name="bytea" length="0"/>
<comment> <![CDATA[CBOR-encoded Datum]]> </comment>
</column>
<column name="redeemer">
<type name="bytea" length="0"/>
<comment> <![CDATA[CBOR-encoded redeemer]]> </comment>
</column>
<column name="script_context" not-null="true">
<type name="bytea" length="0"/>
<comment> <![CDATA[CBOR-encoded ScriptContext]]> </comment>
</column>
<column name="cost_model_params" not-null="true">
<type name="bigint" length="0"/>
</column>
<constraint name="script_evaluation_events_pk" type="pk-constr" table="public.script_evaluation_events">
<columns names="pk" ref-type="src-columns"/>
</constraint>
</table>
<table name="cost_model_params" layers="0" collapse-mode="2" max-obj-count="2" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="320" y="40"/>
<column name="pk" not-null="true">
<type name="bigint" length="0"/>
<comment> <![CDATA[A synthetic PK obtained by hashing param_values using a fast non-cryptographically strong hashing algorithm like XXH3]]> </comment>
</column>
<column name="param_values" not-null="true">
<type name="bigint" length="0" dimension="1"/>
</column>
<constraint name="cost_model_params_pk" type="pk-constr" table="public.cost_model_params">
<columns names="pk" ref-type="src-columns"/>
</constraint>
</table>
<table name="serialised_scripts" layers="0" collapse-mode="2" max-obj-count="3" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="320" y="180"/>
<column name="hash" not-null="true">
<type name="bytea" length="0"/>
</column>
<column name="ledger_language" not-null="true">
<type name="smallint" length="0"/>
</column>
<column name="serialised" not-null="true">
<type name="bytea" length="0"/>
</column>
<constraint name="serialised_scripts_pk" type="pk-constr" table="public.serialised_scripts">
<columns names="hash" ref-type="src-columns"/>
</constraint>
</table>
<table name="deserialised_scripts" layers="0" collapse-mode="2" max-obj-count="2" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="320" y="360"/>
<column name="hash" not-null="true">
<type name="bytea" length="0"/>
</column>
<column name="deserialised" not-null="true">
<type name="jsonb" length="0"/>
</column>
<constraint name="deserialised_scripts_pk" type="pk-constr" table="public.deserialised_scripts">
<columns names="hash" ref-type="src-columns"/>
</constraint>
</table>
<view name="scripts" layers="0" collapse-mode="2" max-obj-count="0" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="1060" y="460"/>
<definition> <![CDATA[select ds.hash, ss.ledger_language, ds.deserialised
from deserialised_scripts as ds
join serialised_scripts as ss on ds.hash = ss.hash]]> </definition>
</view>
<function name="jsonb_array_to_text_array"
window-func="false"
returns-setof="false"
behavior-type="STRICT"
function-type="IMMUTABLE"
security-type="SECURITY INVOKER"
parallel-type="PARALLEL SAFE"
execution-cost="100"
row-amount="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<language name="sql"/>
<return-type>
<type name="text" length="0" dimension="1"/>
</return-type>
<parameter name="_js" in="true">
<type name="jsonb" length="0"/>
</parameter>
<definition> <![CDATA[SELECT ARRAY(SELECT jsonb_array_elements_text(_js) AS jsonb_array_elements_text);]]> </definition>
</function>
<view name="builtin_version_num_usages" layers="0" materialized="true" collapse-mode="2" max-obj-count="0" z-value="0">
<schema name="public"/>
<role name=""plutus-indexer""/>
<comment> <![CDATA[For each combo of builtin function, Plutus ledger language and major protocol version selects how many times it was used by scripts.]]> </comment>
<position x="780" y="520"/>
<definition> <![CDATA[SELECT
UNNEST(
JSONB_ARRAY_TO_TEXT_ARRAY (
JSONB_PATH_QUERY_ARRAY(
DESERIALISED,
'$.**?(@.ctor == "Builtin").fun'::JSONPATH
)
)
) AS BUILTIN,
LEDGER_LANGUAGE,
COUNT(*) AS NUM_USAGES
FROM
SCRIPTS
GROUP BY
BUILTIN,
LEDGER_LANGUAGE
ORDER BY
NUM_USAGES DESC]]> </definition>
</view>
<view name="builtin_version_num_scripts" layers="0" materialized="true" collapse-mode="2" max-obj-count="0" z-value="0">
<schema name="public"/>
<role name=""plutus-indexer""/>
<comment> <![CDATA[For each combo of builtin function, Plutus ledger language and major protocol version selects how many scripts used it.]]> </comment>
<position x="780" y="460"/>
<definition> <![CDATA[SELECT
UNNEST(
JSONB_ARRAY_TO_TEXT_ARRAY (
JSONB_PATH_QUERY_ARRAY(
DESERIALISED,
'$.**?(@."ctor" == "Builtin")."fun"'::JSONPATH
)
)
) AS BUILTIN,
LEDGER_LANGUAGE,
COUNT(DISTINCT HASH) AS NUM_SCRIPTS
FROM
SCRIPTS
GROUP BY
BUILTIN,
LEDGER_LANGUAGE
ORDER BY
NUM_SCRIPTS DESC]]> </definition>
</view>
<view name="script_evaluations" layers="0" collapse-mode="2" max-obj-count="0" z-value="0">
<schema name="public"/>
<role name=""plutus-admin""/>
<position x="1060" y="520"/>
<definition> <![CDATA[SELECT
SEE.SLOT,
SEE.BLOCK,
SEE.MAJOR_PROTOCOL_VERSION,
SEE.EVALUATED_SUCCESSFULLY,
SEE.EXEC_BUDGET_CPU,
SEE.EXEC_BUDGET_MEM,
CMP.PK AS COST_MODEL_KEY,
CMP.PARAM_VALUES AS COST_MODEL_PARAM_VALUES,
SEE.DATUM,
SEE.REDEEMER,
SEE.SCRIPT_CONTEXT,
SS.LEDGER_LANGUAGE,
SS.SERIALISED
FROM
SCRIPT_EVALUATION_EVENTS AS SEE
JOIN SERIALISED_SCRIPTS SS ON SEE.SCRIPT_HASH = SS.HASH
JOIN COST_MODEL_PARAMS CMP ON SEE.COST_MODEL_PARAMS = CMP.PK
]]> </definition>
</view>
<constraint name="cost_model_params_fk" type="fk-constr" comparison-type="MATCH SIMPLE"
upd-action="RESTRICT" del-action="RESTRICT" ref-table="public.cost_model_params" table="public.script_evaluation_events">
<columns names="cost_model_params" ref-type="src-columns"/>
<columns names="pk" ref-type="dst-columns"/>
</constraint>
<constraint name="serialised_scripts_fk" type="fk-constr" comparison-type="MATCH FULL"
upd-action="RESTRICT" del-action="RESTRICT" ref-table="public.serialised_scripts" table="public.script_evaluation_events">
<columns names="script_hash" ref-type="src-columns"/>
<columns names="hash" ref-type="dst-columns"/>
</constraint>
<constraint name="hash_fk" type="fk-constr" comparison-type="MATCH FULL"
upd-action="NO ACTION" del-action="NO ACTION" ref-table="public.serialised_scripts" table="public.deserialised_scripts">
<columns names="hash" ref-type="src-columns"/>
<columns names="hash" ref-type="dst-columns"/>
</constraint>
<relationship name="rel_script_evaluation_events_cost_model_params" type="relfk" layers="0"
src-table="public.script_evaluation_events"
dst-table="public.cost_model_params" reference-fk="cost_model_params_fk"
src-required="false" dst-required="true"/>
<relationship name="rel_script_evaluation_events_serialised_scripts" type="relfk" layers="0"
src-table="public.script_evaluation_events"
dst-table="public.serialised_scripts" reference-fk="serialised_scripts_fk"
src-required="false" dst-required="true"/>
<relationship name="rel_deserialised_scripts_serialised_scripts" type="relfk" layers="0"
src-table="public.deserialised_scripts"
dst-table="public.serialised_scripts" reference-fk="hash_fk"
src-required="false" dst-required="true">
<label ref-type="name-label">
<position x="312.583" y="-23.853"/>
</label>
</relationship>
<permission>
<object name="public.cost_model_params" type="table"/>
<roles names=""plutus-indexer""/>
<privileges insert="true"/>
</permission>
<permission>
<object name="public.deserialised_scripts" type="table"/>
<roles names=""plutus-indexer""/>
<privileges select="true" insert="true"/>
</permission>
<permission>
<object name="public.script_evaluation_events" type="table"/>
<roles names=""plutus-indexer""/>
<privileges select="true" delete="true" insert="true"/>
</permission>
<permission>
<object name="public.serialised_scripts" type="table"/>
<roles names=""plutus-indexer""/>
<privileges select="true" insert="true"/>
</permission>
<permission>
<object name="public.serialised_scripts" type="table"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.script_evaluation_events" type="table"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.deserialised_scripts" type="table"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.cost_model_params" type="table"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.scripts" type="view"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.jsonb_array_to_text_array(jsonb)" type="function"/>
<roles names=""plutus-reader""/>
<privileges execute="true"/>
</permission>
<permission>
<object name="public.builtin_version_num_scripts" type="view"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.builtin_version_num_usages" type="view"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.scripts" type="view"/>
<roles names=""plutus-indexer""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.script_evaluations" type="view"/>
<roles names=""plutus-reader""/>
<privileges select="true"/>
</permission>
<permission>
<object name="public.script_evaluations" type="view"/>
<roles names=""plutus-admin""/>
<privileges select="true"/>
</permission>
</dbmodel>