@sentio/runtime 2.31.0-rc.13 → 2.31.0-rc.15
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/full-service.d.ts +3 -0
- package/lib/full-service.d.ts.map +1 -1
- package/lib/full-service.js +26 -1
- package/lib/full-service.js.map +1 -1
- package/lib/gen/processor/protos/processor.d.ts +12 -0
- package/lib/gen/processor/protos/processor.d.ts.map +1 -1
- package/lib/gen/processor/protos/processor.js +57 -0
- package/lib/gen/processor/protos/processor.js.map +1 -1
- package/lib/global-config.d.ts +8 -0
- package/lib/global-config.d.ts.map +1 -0
- package/lib/global-config.js +22 -0
- package/lib/global-config.js.map +1 -0
- package/lib/global-config.test.d.ts +2 -0
- package/lib/global-config.test.d.ts.map +1 -0
- package/lib/global-config.test.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/service.d.ts.map +1 -1
- package/lib/service.js +16 -7
- package/lib/service.js.map +1 -1
- package/package.json +3 -3
- package/src/full-service.ts +35 -1
- package/src/gen/processor/protos/processor.ts +69 -0
- package/src/global-config.ts +32 -0
- package/src/index.ts +1 -0
- package/src/service.ts +19 -7
@@ -0,0 +1,8 @@
|
|
1
|
+
import { ExecutionConfig } from './gen/processor/protos/processor.js';
|
2
|
+
export interface GlobalConfig {
|
3
|
+
execution: ExecutionConfig;
|
4
|
+
}
|
5
|
+
export declare const GLOBAL_CONFIG: GlobalConfig;
|
6
|
+
export declare function freezeGlobalConfig(): void;
|
7
|
+
export declare function deepFreeze(object: any): any;
|
8
|
+
//# sourceMappingURL=global-config.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"global-config.d.ts","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAA;AAErE,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,eAAe,CAAA;CAC3B;AAGD,eAAO,MAAM,aAAa,EAAE,YAI3B,CAAA;AAED,wBAAgB,kBAAkB,SAEjC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,GAAG,OAcrC"}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
// Experimental global config, only apply to eth for now
|
2
|
+
export const GLOBAL_CONFIG = {
|
3
|
+
execution: {
|
4
|
+
sequential: false
|
5
|
+
}
|
6
|
+
};
|
7
|
+
export function freezeGlobalConfig() {
|
8
|
+
deepFreeze(GLOBAL_CONFIG.execution);
|
9
|
+
}
|
10
|
+
export function deepFreeze(object) {
|
11
|
+
// Retrieve the property names defined on object
|
12
|
+
const propNames = Reflect.ownKeys(object);
|
13
|
+
// Freeze properties before freezing self
|
14
|
+
for (const name of propNames) {
|
15
|
+
const value = object[name];
|
16
|
+
if ((value && typeof value === 'object') || typeof value === 'function') {
|
17
|
+
deepFreeze(value);
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return Object.freeze(object);
|
21
|
+
}
|
22
|
+
//# sourceMappingURL=global-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"global-config.js","sourceRoot":"","sources":["../src/global-config.ts"],"names":[],"mappings":"AAMA,wDAAwD;AACxD,MAAM,CAAC,MAAM,aAAa,GAAiB;IACzC,SAAS,EAAE;QACT,UAAU,EAAE,KAAK;KAClB;CACF,CAAA;AAED,MAAM,UAAU,kBAAkB;IAChC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;AACrC,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,MAAW;IACpC,gDAAgD;IAChD,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAEzC,yCAAyC;IACzC,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE;QAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,CAAA;QAE1B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,EAAE;YACvE,UAAU,CAAC,KAAK,CAAC,CAAA;SAClB;KACF;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAC9B,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"global-config.test.d.ts","sourceRoot":"","sources":["../src/global-config.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"global-config.test.js","sourceRoot":"","sources":["../src/global-config.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAE7B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAI,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC7B,aAAa,CAAC,SAAS,GAAG;YACxB,UAAU,EAAE,IAAI;SACjB,CAAA;QAED,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QACnC,UAAU,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAEnC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE;YAChB,aAAa,CAAC,SAAS,CAAC,UAAU,GAAG,KAAK,CAAA;QAC5C,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA"}
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAE,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAA"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA;AAC1B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,aAAa,EAAqB,MAAM,oBAAoB,CAAA"}
|
package/lib/service.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,WAAW,CAAA;AAG5D,OAAO,EACL,WAAW,EAEX,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,YAAY,EACZ,KAAK,EACN,MAAM,gBAAgB,CAAA;
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,WAAW,CAAA;AAG5D,OAAO,EACL,WAAW,EAEX,sBAAsB,EACtB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,8BAA8B,EAC9B,aAAa,EACb,YAAY,EACZ,KAAK,EACN,MAAM,gBAAgB,CAAA;AAUvB,qBAAa,oBAAqB,YAAW,8BAA8B;IACzE,OAAO,CAAC,OAAO,CAAQ;IAEvB,SAAS,EAAE,KAAK,CAAA;IAGhB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAE3C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAY;gBAEjC,MAAM,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,EAAE,MAAM,IAAI;IAK9D,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAoB9F,KAAK,CAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAsClE,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ1D,eAAe,CAAC,OAAO,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,sBAAsB,CAAC;IA6BxG,cAAc,CAAC,OAAO,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,aAAa,CAAC;IAqBlF,qBAAqB,CAAC,QAAQ,EAAE,aAAa,CAAC,WAAW,CAAC,EAAE,OAAO,EAAE,WAAW;;;;CAcxF"}
|
package/lib/service.js
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
import { ServerError, Status } from 'nice-grpc';
|
2
2
|
import { RichServerError, DebugInfo } from 'nice-grpc-error-details';
|
3
|
-
import { ProcessConfigResponse
|
3
|
+
import { ProcessConfigResponse } from '@sentio/protos';
|
4
4
|
import { PluginManager } from './plugin.js';
|
5
5
|
import { errorString, mergeProcessResults } from './utils.js';
|
6
|
+
import { freezeGlobalConfig, GLOBAL_CONFIG } from './global-config.js';
|
6
7
|
BigInt.prototype.toJSON = function () {
|
7
8
|
return this.toString();
|
8
9
|
};
|
@@ -38,6 +39,7 @@ export class ProcessorServiceImpl {
|
|
38
39
|
if (this.started) {
|
39
40
|
return {};
|
40
41
|
}
|
42
|
+
freezeGlobalConfig();
|
41
43
|
try {
|
42
44
|
// for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {
|
43
45
|
// try {
|
@@ -74,7 +76,14 @@ export class ProcessorServiceImpl {
|
|
74
76
|
return {};
|
75
77
|
}
|
76
78
|
async processBindings(request, options) {
|
77
|
-
const promises =
|
79
|
+
const promises = [];
|
80
|
+
for (const binding of request.bindings) {
|
81
|
+
const promise = this.processBinding(binding);
|
82
|
+
if (GLOBAL_CONFIG.execution.sequential) {
|
83
|
+
await promise;
|
84
|
+
}
|
85
|
+
promises.push(promise);
|
86
|
+
}
|
78
87
|
let promise;
|
79
88
|
try {
|
80
89
|
promise = await Promise.all(promises);
|
@@ -89,7 +98,7 @@ export class ProcessorServiceImpl {
|
|
89
98
|
// updated = true
|
90
99
|
// }
|
91
100
|
return {
|
92
|
-
result
|
101
|
+
result
|
93
102
|
};
|
94
103
|
}
|
95
104
|
async processBinding(request, options) {
|
@@ -100,8 +109,8 @@ export class ProcessorServiceImpl {
|
|
100
109
|
throw new RichServerError(Status.UNAVAILABLE, 'Unhandled exception/rejection in previous request: ' + errorString(this.unhandled), [
|
101
110
|
DebugInfo.fromPartial({
|
102
111
|
detail: this.unhandled.message,
|
103
|
-
stackEntries: this.unhandled.stack?.split('\n')
|
104
|
-
})
|
112
|
+
stackEntries: this.unhandled.stack?.split('\n')
|
113
|
+
})
|
105
114
|
]);
|
106
115
|
}
|
107
116
|
const result = await PluginManager.INSTANCE.processBinding(request);
|
@@ -118,7 +127,7 @@ export class ProcessorServiceImpl {
|
|
118
127
|
// }
|
119
128
|
yield {
|
120
129
|
result,
|
121
|
-
configUpdated: result.states?.configUpdated || false
|
130
|
+
configUpdated: result.states?.configUpdated || false
|
122
131
|
};
|
123
132
|
}
|
124
133
|
}
|
@@ -127,7 +136,7 @@ function recordRuntimeInfo(results, handlerType) {
|
|
127
136
|
for (const list of [results.gauges, results.counters, results.events, results.exports]) {
|
128
137
|
list.forEach((e) => {
|
129
138
|
e.runtimeInfo = {
|
130
|
-
from: handlerType
|
139
|
+
from: handlerType
|
131
140
|
};
|
132
141
|
});
|
133
142
|
}
|
package/lib/service.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,EAML,qBAAqB,
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,WAAW,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAEpE,OAAO,EAML,qBAAqB,EAKtB,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAErE;AAAC,MAAM,CAAC,SAAiB,CAAC,MAAM,GAAG;IAClC,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAA;AACxB,CAAC,CAAA;AAED,MAAM,OAAO,oBAAoB;IACvB,OAAO,GAAG,KAAK,CAAA;IACvB,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AAC,CAAC,CAAA;KACH;AACH,CAAC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@sentio/runtime",
|
3
|
-
"version": "2.31.0-rc.
|
3
|
+
"version": "2.31.0-rc.15",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"type": "module",
|
6
6
|
"exports": {
|
@@ -30,10 +30,10 @@
|
|
30
30
|
"protobufjs": "^7.2.5",
|
31
31
|
"utility-types": "^3.10.0",
|
32
32
|
"winston": "^3.10.0",
|
33
|
-
"@sentio/protos": "2.31.0-rc.
|
33
|
+
"@sentio/protos": "2.31.0-rc.15"
|
34
34
|
},
|
35
35
|
"peerDependencies": {
|
36
|
-
"@sentio/sdk": "^2.31.0-rc.
|
36
|
+
"@sentio/sdk": "^2.31.0-rc.15"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
39
|
"@types/command-line-args": "^5.2.0",
|
package/src/full-service.ts
CHANGED
@@ -10,13 +10,14 @@ import {
|
|
10
10
|
ProcessConfigRequest,
|
11
11
|
ProcessorServiceImplementation,
|
12
12
|
StartRequest,
|
13
|
-
ProcessResult
|
13
|
+
ProcessResult
|
14
14
|
} from './gen/processor/protos/processor.js'
|
15
15
|
|
16
16
|
import { Empty } from '@sentio/protos'
|
17
17
|
import fs from 'fs-extra'
|
18
18
|
import path from 'path'
|
19
19
|
import os from 'os'
|
20
|
+
import { GLOBAL_CONFIG } from './global-config.js'
|
20
21
|
|
21
22
|
function locatePackageJson(pkgId: string) {
|
22
23
|
const m = require.resolve(pkgId)
|
@@ -46,6 +47,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
46
47
|
|
47
48
|
async getConfig(request: ProcessConfigRequest, context: CallContext) {
|
48
49
|
const config = await this.instance.getConfig(request, context)
|
50
|
+
config.executionConfig = GLOBAL_CONFIG.execution
|
51
|
+
|
49
52
|
if (config.contractConfigs) {
|
50
53
|
for (const contract of config.contractConfigs) {
|
51
54
|
// @ts-ignore old fields
|
@@ -72,6 +75,8 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
72
75
|
}
|
73
76
|
|
74
77
|
async processBindings(request: ProcessBindingsRequest, options: CallContext) {
|
78
|
+
request.bindings = request.bindings.sort(dataCompare)
|
79
|
+
|
75
80
|
for (const binding of request.bindings) {
|
76
81
|
this.adjustDataBinding(binding)
|
77
82
|
}
|
@@ -129,3 +134,32 @@ export class FullProcessorServiceImpl implements ProcessorServiceImplementation
|
|
129
134
|
}
|
130
135
|
}
|
131
136
|
}
|
137
|
+
|
138
|
+
// TODO push the logic into sdk
|
139
|
+
function dataCompare(a: DataBinding, b: DataBinding): number {
|
140
|
+
const timeA = getTimestamp(a) || new Date(0)
|
141
|
+
const timeB = getTimestamp(b) || new Date(0)
|
142
|
+
const timeCmp = timeA.getTime() - timeB.getTime()
|
143
|
+
if (timeCmp !== 0) {
|
144
|
+
return timeCmp
|
145
|
+
}
|
146
|
+
return getSecondary(a) - getSecondary(b)
|
147
|
+
}
|
148
|
+
|
149
|
+
function getTimestamp(d: DataBinding): Date | undefined {
|
150
|
+
return (
|
151
|
+
d.data?.ethLog?.timestamp ||
|
152
|
+
d.data?.ethTransaction?.timestamp ||
|
153
|
+
d.data?.ethBlock?.block?.timestamp ||
|
154
|
+
d.data?.ethTrace?.timestamp
|
155
|
+
)
|
156
|
+
}
|
157
|
+
|
158
|
+
function getSecondary(d: DataBinding) {
|
159
|
+
return (
|
160
|
+
d.data?.ethLog?.log?.logIndex ||
|
161
|
+
d.data?.ethTransaction?.transaction?.transactionIndex ||
|
162
|
+
d.data?.ethBlock?.block?.number ||
|
163
|
+
d.data?.ethTrace?.trace?.transactionPosition
|
164
|
+
)
|
165
|
+
}
|
@@ -342,11 +342,16 @@ export interface ProjectConfig {
|
|
342
342
|
version: string;
|
343
343
|
}
|
344
344
|
|
345
|
+
export interface ExecutionConfig {
|
346
|
+
sequential: boolean;
|
347
|
+
}
|
348
|
+
|
345
349
|
export interface ProcessConfigRequest {
|
346
350
|
}
|
347
351
|
|
348
352
|
export interface ProcessConfigResponse {
|
349
353
|
config: ProjectConfig | undefined;
|
354
|
+
executionConfig: ExecutionConfig | undefined;
|
350
355
|
contractConfigs: ContractConfig[];
|
351
356
|
templateInstances: TemplateInstance[];
|
352
357
|
accountConfigs: AccountConfig[];
|
@@ -925,6 +930,57 @@ export const ProjectConfig = {
|
|
925
930
|
},
|
926
931
|
};
|
927
932
|
|
933
|
+
function createBaseExecutionConfig(): ExecutionConfig {
|
934
|
+
return { sequential: false };
|
935
|
+
}
|
936
|
+
|
937
|
+
export const ExecutionConfig = {
|
938
|
+
encode(message: ExecutionConfig, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
939
|
+
if (message.sequential === true) {
|
940
|
+
writer.uint32(8).bool(message.sequential);
|
941
|
+
}
|
942
|
+
return writer;
|
943
|
+
},
|
944
|
+
|
945
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): ExecutionConfig {
|
946
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
947
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
948
|
+
const message = createBaseExecutionConfig();
|
949
|
+
while (reader.pos < end) {
|
950
|
+
const tag = reader.uint32();
|
951
|
+
switch (tag >>> 3) {
|
952
|
+
case 1:
|
953
|
+
message.sequential = reader.bool();
|
954
|
+
break;
|
955
|
+
default:
|
956
|
+
reader.skipType(tag & 7);
|
957
|
+
break;
|
958
|
+
}
|
959
|
+
}
|
960
|
+
return message;
|
961
|
+
},
|
962
|
+
|
963
|
+
fromJSON(object: any): ExecutionConfig {
|
964
|
+
return { sequential: isSet(object.sequential) ? Boolean(object.sequential) : false };
|
965
|
+
},
|
966
|
+
|
967
|
+
toJSON(message: ExecutionConfig): unknown {
|
968
|
+
const obj: any = {};
|
969
|
+
message.sequential !== undefined && (obj.sequential = message.sequential);
|
970
|
+
return obj;
|
971
|
+
},
|
972
|
+
|
973
|
+
create(base?: DeepPartial<ExecutionConfig>): ExecutionConfig {
|
974
|
+
return ExecutionConfig.fromPartial(base ?? {});
|
975
|
+
},
|
976
|
+
|
977
|
+
fromPartial(object: DeepPartial<ExecutionConfig>): ExecutionConfig {
|
978
|
+
const message = createBaseExecutionConfig();
|
979
|
+
message.sequential = object.sequential ?? false;
|
980
|
+
return message;
|
981
|
+
},
|
982
|
+
};
|
983
|
+
|
928
984
|
function createBaseProcessConfigRequest(): ProcessConfigRequest {
|
929
985
|
return {};
|
930
986
|
}
|
@@ -971,6 +1027,7 @@ export const ProcessConfigRequest = {
|
|
971
1027
|
function createBaseProcessConfigResponse(): ProcessConfigResponse {
|
972
1028
|
return {
|
973
1029
|
config: undefined,
|
1030
|
+
executionConfig: undefined,
|
974
1031
|
contractConfigs: [],
|
975
1032
|
templateInstances: [],
|
976
1033
|
accountConfigs: [],
|
@@ -986,6 +1043,9 @@ export const ProcessConfigResponse = {
|
|
986
1043
|
if (message.config !== undefined) {
|
987
1044
|
ProjectConfig.encode(message.config, writer.uint32(10).fork()).ldelim();
|
988
1045
|
}
|
1046
|
+
if (message.executionConfig !== undefined) {
|
1047
|
+
ExecutionConfig.encode(message.executionConfig, writer.uint32(74).fork()).ldelim();
|
1048
|
+
}
|
989
1049
|
for (const v of message.contractConfigs) {
|
990
1050
|
ContractConfig.encode(v!, writer.uint32(18).fork()).ldelim();
|
991
1051
|
}
|
@@ -1020,6 +1080,9 @@ export const ProcessConfigResponse = {
|
|
1020
1080
|
case 1:
|
1021
1081
|
message.config = ProjectConfig.decode(reader, reader.uint32());
|
1022
1082
|
break;
|
1083
|
+
case 9:
|
1084
|
+
message.executionConfig = ExecutionConfig.decode(reader, reader.uint32());
|
1085
|
+
break;
|
1023
1086
|
case 2:
|
1024
1087
|
message.contractConfigs.push(ContractConfig.decode(reader, reader.uint32()));
|
1025
1088
|
break;
|
@@ -1052,6 +1115,7 @@ export const ProcessConfigResponse = {
|
|
1052
1115
|
fromJSON(object: any): ProcessConfigResponse {
|
1053
1116
|
return {
|
1054
1117
|
config: isSet(object.config) ? ProjectConfig.fromJSON(object.config) : undefined,
|
1118
|
+
executionConfig: isSet(object.executionConfig) ? ExecutionConfig.fromJSON(object.executionConfig) : undefined,
|
1055
1119
|
contractConfigs: Array.isArray(object?.contractConfigs)
|
1056
1120
|
? object.contractConfigs.map((e: any) => ContractConfig.fromJSON(e))
|
1057
1121
|
: [],
|
@@ -1079,6 +1143,8 @@ export const ProcessConfigResponse = {
|
|
1079
1143
|
toJSON(message: ProcessConfigResponse): unknown {
|
1080
1144
|
const obj: any = {};
|
1081
1145
|
message.config !== undefined && (obj.config = message.config ? ProjectConfig.toJSON(message.config) : undefined);
|
1146
|
+
message.executionConfig !== undefined &&
|
1147
|
+
(obj.executionConfig = message.executionConfig ? ExecutionConfig.toJSON(message.executionConfig) : undefined);
|
1082
1148
|
if (message.contractConfigs) {
|
1083
1149
|
obj.contractConfigs = message.contractConfigs.map((e) => e ? ContractConfig.toJSON(e) : undefined);
|
1084
1150
|
} else {
|
@@ -1126,6 +1192,9 @@ export const ProcessConfigResponse = {
|
|
1126
1192
|
message.config = (object.config !== undefined && object.config !== null)
|
1127
1193
|
? ProjectConfig.fromPartial(object.config)
|
1128
1194
|
: undefined;
|
1195
|
+
message.executionConfig = (object.executionConfig !== undefined && object.executionConfig !== null)
|
1196
|
+
? ExecutionConfig.fromPartial(object.executionConfig)
|
1197
|
+
: undefined;
|
1129
1198
|
message.contractConfigs = object.contractConfigs?.map((e) => ContractConfig.fromPartial(e)) || [];
|
1130
1199
|
message.templateInstances = object.templateInstances?.map((e) => TemplateInstance.fromPartial(e)) || [];
|
1131
1200
|
message.accountConfigs = object.accountConfigs?.map((e) => AccountConfig.fromPartial(e)) || [];
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import { ExecutionConfig } from './gen/processor/protos/processor.js'
|
2
|
+
|
3
|
+
export interface GlobalConfig {
|
4
|
+
execution: ExecutionConfig
|
5
|
+
}
|
6
|
+
|
7
|
+
// Experimental global config, only apply to eth for now
|
8
|
+
export const GLOBAL_CONFIG: GlobalConfig = {
|
9
|
+
execution: {
|
10
|
+
sequential: false
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
export function freezeGlobalConfig() {
|
15
|
+
deepFreeze(GLOBAL_CONFIG.execution)
|
16
|
+
}
|
17
|
+
|
18
|
+
export function deepFreeze(object: any) {
|
19
|
+
// Retrieve the property names defined on object
|
20
|
+
const propNames = Reflect.ownKeys(object)
|
21
|
+
|
22
|
+
// Freeze properties before freezing self
|
23
|
+
for (const name of propNames) {
|
24
|
+
const value = object[name]
|
25
|
+
|
26
|
+
if ((value && typeof value === 'object') || typeof value === 'function') {
|
27
|
+
deepFreeze(value)
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
return Object.freeze(object)
|
32
|
+
}
|
package/src/index.ts
CHANGED
package/src/service.ts
CHANGED
@@ -11,11 +11,13 @@ import {
|
|
11
11
|
ProcessorServiceImplementation,
|
12
12
|
ProcessResult,
|
13
13
|
StartRequest,
|
14
|
-
Empty
|
14
|
+
Empty
|
15
15
|
} from '@sentio/protos'
|
16
16
|
|
17
17
|
import { PluginManager } from './plugin.js'
|
18
18
|
import { errorString, mergeProcessResults } from './utils.js'
|
19
|
+
import { freezeGlobalConfig, GLOBAL_CONFIG } from './global-config.js'
|
20
|
+
|
19
21
|
;(BigInt.prototype as any).toJSON = function () {
|
20
22
|
return this.toString()
|
21
23
|
}
|
@@ -60,6 +62,8 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
60
62
|
return {}
|
61
63
|
}
|
62
64
|
|
65
|
+
freezeGlobalConfig()
|
66
|
+
|
63
67
|
try {
|
64
68
|
// for (const plugin of ['@sentio/sdk', '@sentio/sdk/eth']) {
|
65
69
|
// try {
|
@@ -100,7 +104,15 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
100
104
|
}
|
101
105
|
|
102
106
|
async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {
|
103
|
-
const promises =
|
107
|
+
const promises = []
|
108
|
+
|
109
|
+
for (const binding of request.bindings) {
|
110
|
+
const promise = this.processBinding(binding)
|
111
|
+
if (GLOBAL_CONFIG.execution.sequential) {
|
112
|
+
await promise
|
113
|
+
}
|
114
|
+
promises.push(promise)
|
115
|
+
}
|
104
116
|
let promise
|
105
117
|
try {
|
106
118
|
promise = await Promise.all(promises)
|
@@ -116,7 +128,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
116
128
|
// }
|
117
129
|
|
118
130
|
return {
|
119
|
-
result
|
131
|
+
result
|
120
132
|
}
|
121
133
|
}
|
122
134
|
|
@@ -131,8 +143,8 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
131
143
|
[
|
132
144
|
DebugInfo.fromPartial({
|
133
145
|
detail: this.unhandled.message,
|
134
|
-
stackEntries: this.unhandled.stack?.split('\n')
|
135
|
-
})
|
146
|
+
stackEntries: this.unhandled.stack?.split('\n')
|
147
|
+
})
|
136
148
|
]
|
137
149
|
)
|
138
150
|
}
|
@@ -151,7 +163,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
151
163
|
// }
|
152
164
|
yield {
|
153
165
|
result,
|
154
|
-
configUpdated: result.states?.configUpdated || false
|
166
|
+
configUpdated: result.states?.configUpdated || false
|
155
167
|
}
|
156
168
|
}
|
157
169
|
}
|
@@ -161,7 +173,7 @@ function recordRuntimeInfo(results: ProcessResult, handlerType: HandlerType) {
|
|
161
173
|
for (const list of [results.gauges, results.counters, results.events, results.exports]) {
|
162
174
|
list.forEach((e) => {
|
163
175
|
e.runtimeInfo = {
|
164
|
-
from: handlerType
|
176
|
+
from: handlerType
|
165
177
|
}
|
166
178
|
})
|
167
179
|
}
|