@sentio/runtime 3.9.0-rc.9 → 4.0.0-rc.2
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/lib/{chunk-VNWNJ423.js → chunk-63SN5KU2.js} +4198 -26357
- package/lib/chunk-63SN5KU2.js.map +1 -0
- package/lib/{chunk-L2A6JPIQ.js → chunk-LSYQ34WX.js} +3 -3
- package/lib/chunk-LSYQ34WX.js.map +1 -0
- package/lib/chunk-MSVN53DI.js +4992 -0
- package/lib/chunk-MSVN53DI.js.map +1 -0
- package/lib/{getMachineId-bsd-QYFPRONP.js → getMachineId-bsd-OV63RCBF.js} +4 -4
- package/lib/getMachineId-bsd-OV63RCBF.js.map +1 -0
- package/lib/{getMachineId-darwin-XC67FIUW.js → getMachineId-darwin-7BY3RHHX.js} +4 -4
- package/lib/getMachineId-darwin-7BY3RHHX.js.map +1 -0
- package/lib/{getMachineId-linux-4G7ZY7LQ.js → getMachineId-linux-SN23MJRK.js} +3 -3
- package/lib/getMachineId-linux-SN23MJRK.js.map +1 -0
- package/lib/{getMachineId-unsupported-5IH5IW7P.js → getMachineId-unsupported-CQYUAEDB.js} +3 -3
- package/lib/getMachineId-unsupported-CQYUAEDB.js.map +1 -0
- package/lib/{getMachineId-win-WSA3TUKL.js → getMachineId-win-NL4ZQSDA.js} +4 -4
- package/lib/getMachineId-win-NL4ZQSDA.js.map +1 -0
- package/lib/index.d.ts +1734 -549
- package/lib/index.js +2 -2
- package/lib/plugin-D-rx1WCp.d.ts +108 -0
- package/lib/processor-runner.js +30992 -10137
- package/lib/processor-runner.js.map +1 -1
- package/package.json +1 -1
- package/src/action-server.ts +3 -2
- package/src/db-context.ts +58 -45
- package/src/endpoints.ts +0 -2
- package/src/full-service.ts +35 -382
- package/src/gen/google/type/money_pb.ts +41 -0
- package/src/gen/processor/protos/processor_pb.ts +3855 -0
- package/src/gen/service/common/protos/common_pb.ts +4456 -0
- package/src/global-config.ts +3 -2
- package/src/logger.ts +13 -5
- package/src/plugin.ts +26 -16
- package/src/processor-runner-program.ts +0 -1
- package/src/processor-runner.ts +29 -25
- package/src/service-v3.ts +54 -56
- package/src/service.ts +94 -87
- package/src/utils.ts +9 -12
- package/lib/chunk-EXIISBRV.js +0 -26084
- package/lib/chunk-EXIISBRV.js.map +0 -1
- package/lib/chunk-L2A6JPIQ.js.map +0 -1
- package/lib/chunk-VNWNJ423.js.map +0 -1
- package/lib/getMachineId-bsd-QYFPRONP.js.map +0 -1
- package/lib/getMachineId-darwin-XC67FIUW.js.map +0 -1
- package/lib/getMachineId-linux-4G7ZY7LQ.js.map +0 -1
- package/lib/getMachineId-unsupported-5IH5IW7P.js.map +0 -1
- package/lib/getMachineId-win-WSA3TUKL.js.map +0 -1
- package/lib/processor-MLp_j8IT.d.ts +0 -864
- package/src/gen/google/protobuf/empty.ts +0 -56
- package/src/gen/google/protobuf/struct.ts +0 -494
- package/src/gen/google/protobuf/timestamp.ts +0 -106
- package/src/gen/google/type/money.ts +0 -122
- package/src/gen/processor/protos/processor.ts +0 -14071
- package/src/gen/service/common/protos/common.ts +0 -15157
package/package.json
CHANGED
package/src/action-server.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PluginManager } from './plugin.js'
|
|
2
|
-
import {
|
|
2
|
+
import { ProcessConfigResponseSchema } from '@sentio/protos'
|
|
3
|
+
import { create } from '@bufbuild/protobuf'
|
|
3
4
|
|
|
4
5
|
export class ActionServer {
|
|
5
6
|
constructor(readonly loader: () => Promise<void>) {}
|
|
@@ -7,7 +8,7 @@ export class ActionServer {
|
|
|
7
8
|
async listen(port: number) {
|
|
8
9
|
const pluginManager = PluginManager.INSTANCE
|
|
9
10
|
await this.loader()
|
|
10
|
-
await pluginManager.configure(
|
|
11
|
+
await pluginManager.configure(create(ProcessConfigResponseSchema))
|
|
11
12
|
console.log('Starting Action Server at:', port)
|
|
12
13
|
await pluginManager.startServer(port)
|
|
13
14
|
}
|
package/src/db-context.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Subject } from 'rxjs'
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
DBRequest_DBUpsert,
|
|
5
|
-
DBResponse,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
TemplateInstance,
|
|
11
|
-
TimeseriesResult
|
|
3
|
+
DBRequestSchema,
|
|
4
|
+
type DBRequest_DBUpsert,
|
|
5
|
+
type DBResponse,
|
|
6
|
+
DBResponseSchema,
|
|
7
|
+
ProcessResultSchema,
|
|
8
|
+
ProcessStreamResponseSchema,
|
|
9
|
+
ProcessStreamResponseV3Schema,
|
|
10
|
+
type TemplateInstance,
|
|
11
|
+
type TimeseriesResult
|
|
12
12
|
} from '@sentio/protos'
|
|
13
|
+
import { create, type MessageInitShape } from '@bufbuild/protobuf'
|
|
13
14
|
import * as process from 'node:process'
|
|
14
15
|
import { dbMetrics } from './metrics.js'
|
|
15
16
|
|
|
@@ -26,13 +27,19 @@ const STORE_BATCH_IDLE = process.env['STORE_BATCH_MAX_IDLE'] ? parseInt(process.
|
|
|
26
27
|
const STORE_BATCH_SIZE = process.env['STORE_BATCH_SIZE'] ? parseInt(process.env['STORE_BATCH_SIZE']) : 10
|
|
27
28
|
const STORE_UPSERT_NO_WAIT = process.env['STORE_UPSERT_NO_WAIT'] === 'true'
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
type
|
|
30
|
+
// Init-shapes carried over the rxjs Subject before being yielded by connect.
|
|
31
|
+
type ProcessStreamResponseInit = MessageInitShape<typeof ProcessStreamResponseSchema>
|
|
32
|
+
type ProcessStreamResponseV3Init = MessageInitShape<typeof ProcessStreamResponseV3Schema>
|
|
33
|
+
|
|
34
|
+
// The DBRequest oneof selection (without the op_id), e.g. { case: 'upsert', value: {...} }.
|
|
35
|
+
// protobuf-es moved the per-op flat fields under the `op` oneof.
|
|
36
|
+
type Request = NonNullable<MessageInitShape<typeof DBRequestSchema>['op']>
|
|
37
|
+
type RequestType = NonNullable<Request['case']>
|
|
31
38
|
|
|
32
39
|
export const timeoutError = new Error('timeout')
|
|
33
40
|
|
|
34
41
|
export interface IStoreContext {
|
|
35
|
-
sendRequest(request:
|
|
42
|
+
sendRequest(request: Request, timeoutSecs?: number): Promise<DBResponse>
|
|
36
43
|
|
|
37
44
|
result(dbResult: DBResponse): void
|
|
38
45
|
|
|
@@ -64,15 +71,15 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
64
71
|
})
|
|
65
72
|
}
|
|
66
73
|
|
|
67
|
-
abstract doSend(resp:
|
|
74
|
+
abstract doSend(resp: ProcessStreamResponseInit | ProcessStreamResponseV3Init): void
|
|
68
75
|
|
|
69
|
-
sendRequest(request:
|
|
70
|
-
if (STORE_BATCH_IDLE > 0 && STORE_BATCH_SIZE > 1 && request.upsert) {
|
|
76
|
+
sendRequest(request: Request, timeoutSecs?: number): Promise<DBResponse> {
|
|
77
|
+
if (STORE_BATCH_IDLE > 0 && STORE_BATCH_SIZE > 1 && request.case === 'upsert') {
|
|
71
78
|
// batch upsert if possible
|
|
72
|
-
return this.sendUpsertInBatch(request.
|
|
79
|
+
return this.sendUpsertInBatch(request.value as DBRequest_DBUpsert)
|
|
73
80
|
}
|
|
74
81
|
|
|
75
|
-
const requestType =
|
|
82
|
+
const requestType = request.case as RequestType
|
|
76
83
|
const opId = StoreContext.opCounter++
|
|
77
84
|
const promise = this.newPromise<DBResponse>(opId, requestType)
|
|
78
85
|
|
|
@@ -88,9 +95,12 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
88
95
|
}
|
|
89
96
|
|
|
90
97
|
this.doSend({
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
98
|
+
value: {
|
|
99
|
+
case: 'dbRequest',
|
|
100
|
+
value: {
|
|
101
|
+
op: request,
|
|
102
|
+
opId
|
|
103
|
+
}
|
|
94
104
|
}
|
|
95
105
|
})
|
|
96
106
|
|
|
@@ -98,9 +108,7 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
98
108
|
|
|
99
109
|
if (requestType === 'upsert' && STORE_UPSERT_NO_WAIT) {
|
|
100
110
|
this.pendings.push(promise)
|
|
101
|
-
return Promise.resolve({
|
|
102
|
-
opId
|
|
103
|
-
} as DBResponse)
|
|
111
|
+
return Promise.resolve(create(DBResponseSchema, { opId }))
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
return Promise.race(promises)
|
|
@@ -130,8 +138,8 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
130
138
|
if (defer.requestType) {
|
|
131
139
|
recv_counts[defer.requestType]?.add(1)
|
|
132
140
|
}
|
|
133
|
-
if (dbResult.error) {
|
|
134
|
-
defer.reject(new Error(dbResult.
|
|
141
|
+
if (dbResult.value.case === 'error') {
|
|
142
|
+
defer.reject(new Error(dbResult.value.value))
|
|
135
143
|
} else {
|
|
136
144
|
defer.resolve(dbResult)
|
|
137
145
|
}
|
|
@@ -143,12 +151,12 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
143
151
|
error(processId: number, e: any) {
|
|
144
152
|
const stack = e.stack
|
|
145
153
|
console.error('process error', processId, e, stack)
|
|
146
|
-
const errorResult =
|
|
154
|
+
const errorResult = create(ProcessResultSchema, {
|
|
147
155
|
states: {
|
|
148
156
|
error: e?.toString() + (stack ? `\n${stack}` : '')
|
|
149
157
|
}
|
|
150
158
|
})
|
|
151
|
-
this.doSend({ result: errorResult, processId })
|
|
159
|
+
this.doSend({ value: { case: 'result', value: errorResult }, processId })
|
|
152
160
|
}
|
|
153
161
|
|
|
154
162
|
close() {
|
|
@@ -182,9 +190,7 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
182
190
|
this.sendBatch()
|
|
183
191
|
}
|
|
184
192
|
if (STORE_UPSERT_NO_WAIT) {
|
|
185
|
-
return {
|
|
186
|
-
opId
|
|
187
|
-
}
|
|
193
|
+
return create(DBResponseSchema, { opId })
|
|
188
194
|
}
|
|
189
195
|
|
|
190
196
|
return promise
|
|
@@ -207,9 +213,7 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
207
213
|
|
|
208
214
|
if (STORE_UPSERT_NO_WAIT) {
|
|
209
215
|
this.pendings.push(promise)
|
|
210
|
-
return {
|
|
211
|
-
opId: this.upsertBatch.opId
|
|
212
|
-
}
|
|
216
|
+
return create(DBResponseSchema, { opId: this.upsertBatch.opId })
|
|
213
217
|
} else {
|
|
214
218
|
return promise
|
|
215
219
|
}
|
|
@@ -223,9 +227,12 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
223
227
|
clearTimeout(timer)
|
|
224
228
|
this.upsertBatch = undefined
|
|
225
229
|
this.doSend({
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
value: {
|
|
231
|
+
case: 'dbRequest',
|
|
232
|
+
value: {
|
|
233
|
+
op: { case: 'upsert', value: request },
|
|
234
|
+
opId
|
|
235
|
+
}
|
|
229
236
|
}
|
|
230
237
|
})
|
|
231
238
|
send_counts['upsert']?.add(1)
|
|
@@ -241,13 +248,13 @@ export abstract class AbstractStoreContext implements IStoreContext {
|
|
|
241
248
|
|
|
242
249
|
export class StoreContext extends AbstractStoreContext {
|
|
243
250
|
constructor(
|
|
244
|
-
readonly subject: Subject<
|
|
251
|
+
readonly subject: Subject<ProcessStreamResponseInit>,
|
|
245
252
|
processId: number
|
|
246
253
|
) {
|
|
247
254
|
super(processId)
|
|
248
255
|
}
|
|
249
256
|
|
|
250
|
-
doSend(resp:
|
|
257
|
+
doSend(resp: ProcessStreamResponseInit) {
|
|
251
258
|
this.subject.next({
|
|
252
259
|
...resp,
|
|
253
260
|
processId: this.processId
|
|
@@ -259,7 +266,7 @@ export class StoreContext extends AbstractStoreContext {
|
|
|
259
266
|
export class DataBindingContext extends AbstractStoreContext implements IDataBindingContext {
|
|
260
267
|
constructor(
|
|
261
268
|
readonly processId: number,
|
|
262
|
-
readonly subject: Subject<
|
|
269
|
+
readonly subject: Subject<ProcessStreamResponseV3Init>
|
|
263
270
|
) {
|
|
264
271
|
super(processId)
|
|
265
272
|
}
|
|
@@ -267,22 +274,28 @@ export class DataBindingContext extends AbstractStoreContext implements IDataBin
|
|
|
267
274
|
sendTemplateRequest(templates: Array<TemplateInstance>, unbind: boolean) {
|
|
268
275
|
this.subject.next({
|
|
269
276
|
processId: this.processId,
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
277
|
+
value: {
|
|
278
|
+
case: 'tplRequest',
|
|
279
|
+
value: {
|
|
280
|
+
templates,
|
|
281
|
+
remove: unbind
|
|
282
|
+
}
|
|
273
283
|
}
|
|
274
284
|
})
|
|
275
285
|
}
|
|
276
286
|
sendTimeseriesRequest(timeseries: Array<TimeseriesResult>) {
|
|
277
287
|
this.subject.next({
|
|
278
288
|
processId: this.processId,
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
value: {
|
|
290
|
+
case: 'tsRequest',
|
|
291
|
+
value: {
|
|
292
|
+
data: timeseries
|
|
293
|
+
}
|
|
281
294
|
}
|
|
282
295
|
})
|
|
283
296
|
}
|
|
284
297
|
|
|
285
|
-
doSend(resp:
|
|
298
|
+
doSend(resp: ProcessStreamResponseV3Init) {
|
|
286
299
|
this.subject.next({
|
|
287
300
|
...resp,
|
|
288
301
|
processId: this.processId
|
package/src/endpoints.ts
CHANGED
|
@@ -6,7 +6,6 @@ export class Endpoints {
|
|
|
6
6
|
static INSTANCE: Endpoints = new Endpoints()
|
|
7
7
|
|
|
8
8
|
concurrency = 8
|
|
9
|
-
chainQueryAPI = ''
|
|
10
9
|
priceFeedAPI = ''
|
|
11
10
|
|
|
12
11
|
chainServer = new Map<string, string>()
|
|
@@ -27,7 +26,6 @@ export function configureEndpoints(options: any) {
|
|
|
27
26
|
|
|
28
27
|
Endpoints.INSTANCE.concurrency = concurrencyOverride ?? options.concurrency
|
|
29
28
|
Endpoints.INSTANCE.batchCount = batchCountOverride ?? options.batchCount
|
|
30
|
-
Endpoints.INSTANCE.chainQueryAPI = options.chainqueryServer
|
|
31
29
|
Endpoints.INSTANCE.priceFeedAPI = options.pricefeedServer
|
|
32
30
|
|
|
33
31
|
for (const [id, config] of Object.entries(chainsConfig)) {
|