@sentio/runtime 2.40.0-rc.16 → 2.40.0-rc.18
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-K6CPN5YU.js → chunk-FYV7R6QO.js} +17 -17
- package/lib/index.d.ts +12 -4
- package/lib/index.js +1 -1
- package/lib/processor-runner.js +1 -1
- package/package.json +1 -1
- package/src/plugin.ts +7 -3
- package/src/service.ts +13 -11
- package/src/utils.ts +1 -1
@@ -49600,7 +49600,7 @@ var Plugin = class {
|
|
49600
49600
|
async processBinding(request, preparedData) {
|
49601
49601
|
return ProcessResult.create();
|
49602
49602
|
}
|
49603
|
-
async preprocessBinding(request) {
|
49603
|
+
async preprocessBinding(request, preprocessStore) {
|
49604
49604
|
return PreprocessResult.create();
|
49605
49605
|
}
|
49606
49606
|
};
|
@@ -49642,13 +49642,13 @@ var _PluginManager = class {
|
|
49642
49642
|
return plugin.processBinding(request, preparedData);
|
49643
49643
|
});
|
49644
49644
|
}
|
49645
|
-
preprocessBinding(request, dbContext) {
|
49645
|
+
preprocessBinding(request, preprocessStore, dbContext) {
|
49646
49646
|
const plugin = this.typesToPlugin.get(request.handlerType);
|
49647
49647
|
if (!plugin) {
|
49648
49648
|
throw new Error(`No plugin for ${request.handlerType}`);
|
49649
49649
|
}
|
49650
49650
|
return this.dbContextLocalStorage.run(dbContext, () => {
|
49651
|
-
return plugin.preprocessBinding(request);
|
49651
|
+
return plugin.preprocessBinding(request, preprocessStore);
|
49652
49652
|
});
|
49653
49653
|
}
|
49654
49654
|
};
|
@@ -59531,7 +59531,7 @@ function makeEthCallKey(param) {
|
|
59531
59531
|
throw new Error("null context for eth call");
|
59532
59532
|
}
|
59533
59533
|
const { chainId, address, blockTag } = param.context;
|
59534
|
-
return `${chainId}|${address}|${blockTag}|${param.calldata}
|
59534
|
+
return `${chainId}|${address}|${blockTag}|${param.calldata}`.toLowerCase();
|
59535
59535
|
}
|
59536
59536
|
|
59537
59537
|
// src/endpoints.ts
|
@@ -78468,7 +78468,7 @@ var ProcessorServiceImpl = class {
|
|
78468
78468
|
return {};
|
78469
78469
|
}
|
78470
78470
|
async processBindings(request, options) {
|
78471
|
-
const preparedData = await this.preprocessBindings(request.bindings, void 0, options);
|
78471
|
+
const preparedData = await this.preprocessBindings(request.bindings, {}, void 0, options);
|
78472
78472
|
const promises = [];
|
78473
78473
|
for (const binding of request.bindings) {
|
78474
78474
|
const promise2 = this.processBinding(binding, preparedData);
|
@@ -78488,11 +78488,11 @@ var ProcessorServiceImpl = class {
|
|
78488
78488
|
result
|
78489
78489
|
};
|
78490
78490
|
}
|
78491
|
-
async preprocessBindings(bindings, dbContext, options) {
|
78491
|
+
async preprocessBindings(bindings, preprocessStore, dbContext, options) {
|
78492
78492
|
console.debug(`preprocessBindings start, bindings: ${bindings.length}`);
|
78493
78493
|
const promises = [];
|
78494
78494
|
for (const binding of bindings) {
|
78495
|
-
promises.push(this.preprocessBinding(binding, dbContext, options));
|
78495
|
+
promises.push(this.preprocessBinding(binding, preprocessStore, dbContext, options));
|
78496
78496
|
}
|
78497
78497
|
let preprocessResults;
|
78498
78498
|
try {
|
@@ -78500,10 +78500,6 @@ var ProcessorServiceImpl = class {
|
|
78500
78500
|
} catch (e) {
|
78501
78501
|
throw e;
|
78502
78502
|
}
|
78503
|
-
console.debug(
|
78504
|
-
"ethCallParams: ",
|
78505
|
-
preprocessResults.map((r) => r.ethCallParams)
|
78506
|
-
);
|
78507
78503
|
const groupedRequests = /* @__PURE__ */ new Map();
|
78508
78504
|
const providers2 = /* @__PURE__ */ new Map();
|
78509
78505
|
for (const result of preprocessResults) {
|
@@ -78523,14 +78519,17 @@ var ProcessorServiceImpl = class {
|
|
78523
78519
|
const callPromises = [];
|
78524
78520
|
for (const params of groupedRequests.values()) {
|
78525
78521
|
const { chainId, address, blockTag } = params[0].context;
|
78526
|
-
console.log(`chain: ${chainId}, address: ${address}, blockTag: ${blockTag}, totalCalls: ${params.length}`);
|
78527
78522
|
for (const param of params) {
|
78528
78523
|
callPromises.push(
|
78529
78524
|
providers2.get(chainId).call({
|
78530
78525
|
to: address,
|
78531
78526
|
data: param.calldata,
|
78532
78527
|
blockTag
|
78533
|
-
}).then((result) =>
|
78528
|
+
}).then((result) => {
|
78529
|
+
const ret = [makeEthCallKey(param), result];
|
78530
|
+
console.log(`got eth call result, key: ${ret[0]}, result: ${result}`);
|
78531
|
+
return ret;
|
78532
|
+
})
|
78534
78533
|
);
|
78535
78534
|
}
|
78536
78535
|
}
|
@@ -78545,7 +78544,7 @@ var ProcessorServiceImpl = class {
|
|
78545
78544
|
ethCallResults: results
|
78546
78545
|
};
|
78547
78546
|
}
|
78548
|
-
async preprocessBinding(request, dbContext, options) {
|
78547
|
+
async preprocessBinding(request, preprocessStore, dbContext, options) {
|
78549
78548
|
if (!this.started) {
|
78550
78549
|
throw new import_nice_grpc.ServerError(import_nice_grpc.Status.UNAVAILABLE, "Service Not started.");
|
78551
78550
|
}
|
@@ -78561,7 +78560,7 @@ var ProcessorServiceImpl = class {
|
|
78561
78560
|
]
|
78562
78561
|
);
|
78563
78562
|
}
|
78564
|
-
return await PluginManager.INSTANCE.preprocessBinding(request, dbContext);
|
78563
|
+
return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext);
|
78565
78564
|
}
|
78566
78565
|
async processBinding(request, preparedData, options) {
|
78567
78566
|
if (!this.started) {
|
@@ -78589,6 +78588,7 @@ var ProcessorServiceImpl = class {
|
|
78589
78588
|
}
|
78590
78589
|
const subject = new import_rxjs.Subject();
|
78591
78590
|
this.handleRequests(requests, subject).then(() => {
|
78591
|
+
console.log("clearing prepared data");
|
78592
78592
|
this.preparedData = { ethCallResults: {} };
|
78593
78593
|
subject.complete();
|
78594
78594
|
}).catch((e) => {
|
@@ -78599,14 +78599,14 @@ var ProcessorServiceImpl = class {
|
|
78599
78599
|
}
|
78600
78600
|
async handlePreprocessRequests(requests, subject) {
|
78601
78601
|
const contexts = new Contexts();
|
78602
|
+
const preprocessStore = {};
|
78602
78603
|
for await (const request of requests) {
|
78603
78604
|
try {
|
78604
|
-
console.debug("received request:", request);
|
78605
78605
|
if (request.bindings) {
|
78606
78606
|
const bindings = request.bindings.bindings;
|
78607
78607
|
const dbContext = contexts.new(request.processId, subject);
|
78608
78608
|
const start = Date.now();
|
78609
|
-
this.preprocessBindings(bindings, dbContext).then((preparedData) => {
|
78609
|
+
this.preprocessBindings(bindings, preprocessStore, dbContext, void 0).then((preparedData) => {
|
78610
78610
|
this.preparedData = {
|
78611
78611
|
ethCallResults: {
|
78612
78612
|
...this.preparedData?.ethCallResults,
|
package/lib/index.d.ts
CHANGED
@@ -41,7 +41,9 @@ declare abstract class Plugin {
|
|
41
41
|
*/
|
42
42
|
stateDiff(config: ProcessConfigResponse): boolean;
|
43
43
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined): Promise<ProcessResult>;
|
44
|
-
preprocessBinding(request: DataBinding
|
44
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
45
|
+
[k: string]: any;
|
46
|
+
}): Promise<PreprocessResult>;
|
45
47
|
}
|
46
48
|
declare class PluginManager {
|
47
49
|
static INSTANCE: PluginManager;
|
@@ -56,7 +58,9 @@ declare class PluginManager {
|
|
56
58
|
*/
|
57
59
|
stateDiff(config: ProcessConfigResponse): boolean;
|
58
60
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, dbContext?: StoreContext): Promise<ProcessResult>;
|
59
|
-
preprocessBinding(request: DataBinding,
|
61
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
62
|
+
[k: string]: any;
|
63
|
+
}, dbContext?: StoreContext): Promise<PreprocessResult>;
|
60
64
|
}
|
61
65
|
|
62
66
|
declare class State {
|
@@ -113,8 +117,12 @@ declare class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
113
117
|
start(request: StartRequest, context: CallContext): Promise<Empty>;
|
114
118
|
stop(request: Empty, context: CallContext): Promise<Empty>;
|
115
119
|
processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse>;
|
116
|
-
preprocessBindings(bindings: DataBinding[],
|
117
|
-
|
120
|
+
preprocessBindings(bindings: DataBinding[], preprocessStore: {
|
121
|
+
[k: string]: any;
|
122
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreparedData>;
|
123
|
+
preprocessBinding(request: DataBinding, preprocessStore: {
|
124
|
+
[k: string]: any;
|
125
|
+
}, dbContext?: StoreContext, options?: CallContext): Promise<PreprocessResult>;
|
118
126
|
processBinding(request: DataBinding, preparedData: PreparedData | undefined, options?: CallContext): Promise<ProcessResult>;
|
119
127
|
processBindingsStream(requests: AsyncIterable<ProcessStreamRequest>, context: CallContext): AsyncGenerator<{
|
120
128
|
processId?: number | undefined;
|
package/lib/index.js
CHANGED
package/lib/processor-runner.js
CHANGED
package/package.json
CHANGED
package/src/plugin.ts
CHANGED
@@ -28,7 +28,7 @@ export abstract class Plugin {
|
|
28
28
|
return ProcessResult.create()
|
29
29
|
}
|
30
30
|
|
31
|
-
async preprocessBinding(request: DataBinding): Promise<PreprocessResult> {
|
31
|
+
async preprocessBinding(request: DataBinding, preprocessStore: { [k: string]: any }): Promise<PreprocessResult> {
|
32
32
|
return PreprocessResult.create()
|
33
33
|
}
|
34
34
|
}
|
@@ -84,13 +84,17 @@ export class PluginManager {
|
|
84
84
|
})
|
85
85
|
}
|
86
86
|
|
87
|
-
preprocessBinding(
|
87
|
+
preprocessBinding(
|
88
|
+
request: DataBinding,
|
89
|
+
preprocessStore: { [k: string]: any },
|
90
|
+
dbContext?: StoreContext
|
91
|
+
): Promise<PreprocessResult> {
|
88
92
|
const plugin = this.typesToPlugin.get(request.handlerType)
|
89
93
|
if (!plugin) {
|
90
94
|
throw new Error(`No plugin for ${request.handlerType}`)
|
91
95
|
}
|
92
96
|
return this.dbContextLocalStorage.run(dbContext, () => {
|
93
|
-
return plugin.preprocessBinding(request)
|
97
|
+
return plugin.preprocessBinding(request, preprocessStore)
|
94
98
|
})
|
95
99
|
}
|
96
100
|
}
|
package/src/service.ts
CHANGED
@@ -128,7 +128,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
128
128
|
}
|
129
129
|
|
130
130
|
async processBindings(request: ProcessBindingsRequest, options?: CallContext): Promise<ProcessBindingResponse> {
|
131
|
-
const preparedData = await this.preprocessBindings(request.bindings, undefined, options)
|
131
|
+
const preparedData = await this.preprocessBindings(request.bindings, {}, undefined, options)
|
132
132
|
|
133
133
|
const promises = []
|
134
134
|
for (const binding of request.bindings) {
|
@@ -159,13 +159,14 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
159
159
|
|
160
160
|
async preprocessBindings(
|
161
161
|
bindings: DataBinding[],
|
162
|
+
preprocessStore: { [k: string]: any },
|
162
163
|
dbContext?: StoreContext,
|
163
164
|
options?: CallContext
|
164
165
|
): Promise<PreparedData> {
|
165
166
|
console.debug(`preprocessBindings start, bindings: ${bindings.length}`)
|
166
167
|
const promises = []
|
167
168
|
for (const binding of bindings) {
|
168
|
-
promises.push(this.preprocessBinding(binding, dbContext, options))
|
169
|
+
promises.push(this.preprocessBinding(binding, preprocessStore, dbContext, options))
|
169
170
|
}
|
170
171
|
let preprocessResults: PreprocessResult[]
|
171
172
|
try {
|
@@ -173,10 +174,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
173
174
|
} catch (e) {
|
174
175
|
throw e
|
175
176
|
}
|
176
|
-
console.debug(
|
177
|
-
'ethCallParams: ',
|
178
|
-
preprocessResults.map((r) => r.ethCallParams)
|
179
|
-
)
|
180
177
|
const groupedRequests = new Map<string, EthCallParam[]>()
|
181
178
|
const providers = new Map<string, Provider>()
|
182
179
|
for (const result of preprocessResults) {
|
@@ -197,7 +194,6 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
197
194
|
const callPromises = []
|
198
195
|
for (const params of groupedRequests.values()) {
|
199
196
|
const { chainId, address, blockTag } = params[0].context!
|
200
|
-
console.log(`chain: ${chainId}, address: ${address}, blockTag: ${blockTag}, totalCalls: ${params.length}`)
|
201
197
|
// TODO multicall
|
202
198
|
for (const param of params) {
|
203
199
|
callPromises.push(
|
@@ -208,7 +204,11 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
208
204
|
data: param.calldata,
|
209
205
|
blockTag
|
210
206
|
})
|
211
|
-
.then((result) =>
|
207
|
+
.then((result) => {
|
208
|
+
const ret = [makeEthCallKey(param), result]
|
209
|
+
console.log(`got eth call result, key: ${ret[0]}, result: ${result}`)
|
210
|
+
return ret
|
211
|
+
})
|
212
212
|
)
|
213
213
|
}
|
214
214
|
}
|
@@ -226,6 +226,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
226
226
|
|
227
227
|
async preprocessBinding(
|
228
228
|
request: DataBinding,
|
229
|
+
preprocessStore: { [k: string]: any },
|
229
230
|
dbContext?: StoreContext,
|
230
231
|
options?: CallContext
|
231
232
|
): Promise<PreprocessResult> {
|
@@ -244,7 +245,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
244
245
|
]
|
245
246
|
)
|
246
247
|
}
|
247
|
-
return await PluginManager.INSTANCE.preprocessBinding(request, dbContext)
|
248
|
+
return await PluginManager.INSTANCE.preprocessBinding(request, preprocessStore, dbContext)
|
248
249
|
}
|
249
250
|
|
250
251
|
async processBinding(
|
@@ -280,6 +281,7 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
280
281
|
const subject = new Subject<DeepPartial<ProcessStreamResponse>>()
|
281
282
|
this.handleRequests(requests, subject)
|
282
283
|
.then(() => {
|
284
|
+
console.log('clearing prepared data')
|
283
285
|
this.preparedData = { ethCallResults: {} }
|
284
286
|
subject.complete()
|
285
287
|
})
|
@@ -295,15 +297,15 @@ export class ProcessorServiceImpl implements ProcessorServiceImplementation {
|
|
295
297
|
subject: Subject<DeepPartial<PreprocessStreamResponse>>
|
296
298
|
) {
|
297
299
|
const contexts = new Contexts()
|
300
|
+
const preprocessStore: { [k: string]: any } = {}
|
298
301
|
|
299
302
|
for await (const request of requests) {
|
300
303
|
try {
|
301
|
-
console.debug('received request:', request)
|
302
304
|
if (request.bindings) {
|
303
305
|
const bindings = request.bindings.bindings
|
304
306
|
const dbContext = contexts.new(request.processId, subject)
|
305
307
|
const start = Date.now()
|
306
|
-
this.preprocessBindings(bindings, dbContext)
|
308
|
+
this.preprocessBindings(bindings, preprocessStore, dbContext, undefined)
|
307
309
|
.then((preparedData) => {
|
308
310
|
// TODO maybe not proper to pass data in this way
|
309
311
|
this.preparedData = {
|
package/src/utils.ts
CHANGED
@@ -34,5 +34,5 @@ export function makeEthCallKey(param: EthCallParam) {
|
|
34
34
|
throw new Error('null context for eth call')
|
35
35
|
}
|
36
36
|
const { chainId, address, blockTag } = param.context
|
37
|
-
return `${chainId}|${address}|${blockTag}|${param.calldata}
|
37
|
+
return `${chainId}|${address}|${blockTag}|${param.calldata}`.toLowerCase()
|
38
38
|
}
|