@sentio/runtime 2.40.0-rc.5 → 2.40.0-rc.50
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/LICENSE +55 -0
- package/lib/chunk-N7A3MJFE.js +131 -0
- package/lib/chunk-N7A3MJFE.js.map +1 -0
- package/lib/index.d.ts +22 -9
- package/lib/index.js +2 -93
- package/lib/index.js.map +1 -0
- package/lib/processor-runner.d.ts +3 -0
- package/lib/processor-runner.js +58 -51468
- package/lib/processor-runner.js.map +1 -0
- package/package.json +14 -36
- package/src/db-context.ts +51 -44
- package/src/decode-benchmark.ts +0 -0
- package/src/gen/processor/protos/processor.ts +121 -76
- package/src/index.ts +1 -0
- package/src/metrics.ts +138 -0
- package/src/multicall.ts +1615 -0
- package/src/otlp.ts +50 -0
- package/src/plugin.ts +7 -3
- package/src/processor-runner.ts +64 -21
- package/src/provider.ts +3 -9
- package/src/service.ts +105 -42
- package/src/tsup.config.ts +2 -0
- package/src/utils.ts +11 -3
- package/.eslintrc.json +0 -5
- package/chains-config.json +0 -9
- package/lib/chunk-FFU5RYDX.js +0 -78856
- package/src/global-config.test.ts +0 -19
- package/src/logger.test.ts +0 -26
- package/src/seq-mode.test.ts +0 -80
- package/src/service.test.ts +0 -51
- package/src/state-storage.test.ts +0 -25
- package/tsconfig.json +0 -10
@@ -1,19 +0,0 @@
|
|
1
|
-
import { describe, test } from 'node:test'
|
2
|
-
import { deepFreeze, GLOBAL_CONFIG } from './global-config.js'
|
3
|
-
import { assert } from 'chai'
|
4
|
-
|
5
|
-
describe('global config test', () => {
|
6
|
-
test('freeze test', async () => {
|
7
|
-
GLOBAL_CONFIG.execution = {
|
8
|
-
sequential: true,
|
9
|
-
forceExactBlockTime: false
|
10
|
-
}
|
11
|
-
|
12
|
-
deepFreeze(GLOBAL_CONFIG.execution)
|
13
|
-
deepFreeze(GLOBAL_CONFIG.execution)
|
14
|
-
|
15
|
-
assert.throw(() => {
|
16
|
-
GLOBAL_CONFIG.execution.sequential = false
|
17
|
-
})
|
18
|
-
})
|
19
|
-
})
|
package/src/logger.test.ts
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
import { describe, test } from 'node:test'
|
2
|
-
import { setupLogger } from './logger.js'
|
3
|
-
|
4
|
-
describe('Test logger', () => {
|
5
|
-
test('check log output', () => {
|
6
|
-
const object = { a: 'asdf', b: 'Asdf' }
|
7
|
-
|
8
|
-
console.log(JSON.stringify(object), object)
|
9
|
-
setupLogger(false, true)
|
10
|
-
console.log('asdf')
|
11
|
-
console.log('asdf')
|
12
|
-
console.log(1111, true, 'asdf')
|
13
|
-
console.log(111111111n)
|
14
|
-
|
15
|
-
// console.log(object)
|
16
|
-
console.log(JSON.stringify(object), object)
|
17
|
-
})
|
18
|
-
|
19
|
-
test('check debug log', () => {
|
20
|
-
console.log('check debug log')
|
21
|
-
setupLogger(false, true)
|
22
|
-
console.debug('debug=true')
|
23
|
-
setupLogger(true, false)
|
24
|
-
console.debug('debug=false')
|
25
|
-
})
|
26
|
-
})
|
package/src/seq-mode.test.ts
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
import { before, describe, test } from 'node:test'
|
2
|
-
import { ProcessorServiceImpl } from './service.js'
|
3
|
-
import { FullProcessorServiceImpl } from './full-service.js'
|
4
|
-
import { CallContext } from 'nice-grpc-common'
|
5
|
-
import { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'
|
6
|
-
import { Plugin, PluginManager } from './plugin.js'
|
7
|
-
import { assert } from 'chai'
|
8
|
-
import { GLOBAL_CONFIG } from './global-config.js'
|
9
|
-
export const TEST_CONTEXT: CallContext = <CallContext>{}
|
10
|
-
|
11
|
-
let testRequest: DataBinding
|
12
|
-
|
13
|
-
class TestPlugin extends Plugin {
|
14
|
-
async processBinding(request: DataBinding): Promise<ProcessResult> {
|
15
|
-
testRequest = request
|
16
|
-
return ProcessResult.fromPartial({})
|
17
|
-
}
|
18
|
-
supportedHandlers = [HandlerType.ETH_BLOCK]
|
19
|
-
}
|
20
|
-
|
21
|
-
describe('Test seq mode', () => {
|
22
|
-
const baseService = new ProcessorServiceImpl(async () => {
|
23
|
-
PluginManager.INSTANCE.plugins = []
|
24
|
-
PluginManager.INSTANCE.register(new TestPlugin())
|
25
|
-
})
|
26
|
-
const service = new FullProcessorServiceImpl(baseService)
|
27
|
-
|
28
|
-
before(async () => {
|
29
|
-
GLOBAL_CONFIG.execution.sequential = true
|
30
|
-
|
31
|
-
await service.start({ templateInstances: [] }, TEST_CONTEXT)
|
32
|
-
})
|
33
|
-
|
34
|
-
test('Check block dispatch in seq', async () => {
|
35
|
-
const binding1: DataBinding = {
|
36
|
-
data: {
|
37
|
-
raw: new Uint8Array(),
|
38
|
-
ethBlock: {
|
39
|
-
block: {
|
40
|
-
number: '0x1',
|
41
|
-
timestamp: '0x65ed3a46'
|
42
|
-
}
|
43
|
-
}
|
44
|
-
},
|
45
|
-
handlerType: HandlerType.ETH_BLOCK,
|
46
|
-
handlerIds: [0]
|
47
|
-
}
|
48
|
-
|
49
|
-
const binding2 = {
|
50
|
-
data: {
|
51
|
-
raw: new Uint8Array(),
|
52
|
-
ethBlock: {
|
53
|
-
block: {
|
54
|
-
number: '0x2',
|
55
|
-
timestamp: '0x65ed3b46'
|
56
|
-
}
|
57
|
-
}
|
58
|
-
},
|
59
|
-
handlerType: HandlerType.ETH_BLOCK,
|
60
|
-
handlerIds: [0]
|
61
|
-
}
|
62
|
-
|
63
|
-
const binding3 = {
|
64
|
-
data: {
|
65
|
-
raw: new Uint8Array(),
|
66
|
-
ethBlock: {
|
67
|
-
block: {
|
68
|
-
number: '0x1',
|
69
|
-
timestamp: '0x65ed3c46'
|
70
|
-
}
|
71
|
-
}
|
72
|
-
},
|
73
|
-
handlerType: HandlerType.ETH_BLOCK,
|
74
|
-
handlerIds: [0]
|
75
|
-
}
|
76
|
-
|
77
|
-
await service.processBindings({ bindings: [binding2, binding1, binding3] }, TEST_CONTEXT)
|
78
|
-
assert(testRequest.handlerType === HandlerType.ETH_BLOCK)
|
79
|
-
})
|
80
|
-
})
|
package/src/service.test.ts
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
import { before, describe, test } from 'node:test'
|
2
|
-
import { ProcessorServiceImpl } from './service.js'
|
3
|
-
import { FullProcessorServiceImpl } from './full-service.js'
|
4
|
-
import { CallContext } from 'nice-grpc-common'
|
5
|
-
import { DataBinding, HandlerType, ProcessResult } from './gen/processor/protos/processor.js'
|
6
|
-
import { Plugin, PluginManager } from './plugin.js'
|
7
|
-
import { assert } from 'chai'
|
8
|
-
|
9
|
-
export const TEST_CONTEXT: CallContext = <CallContext>{}
|
10
|
-
|
11
|
-
// TODO use mock
|
12
|
-
let testRequest: DataBinding
|
13
|
-
|
14
|
-
class TestPlugin extends Plugin {
|
15
|
-
async processBinding(request: DataBinding): Promise<ProcessResult> {
|
16
|
-
testRequest = request
|
17
|
-
return ProcessResult.fromPartial({})
|
18
|
-
}
|
19
|
-
supportedHandlers = [HandlerType.UNKNOWN, HandlerType.APT_EVENT]
|
20
|
-
}
|
21
|
-
|
22
|
-
describe('Test Service Compatibility', () => {
|
23
|
-
const baseService = new ProcessorServiceImpl(async () => {
|
24
|
-
PluginManager.INSTANCE.plugins = []
|
25
|
-
PluginManager.INSTANCE.register(new TestPlugin())
|
26
|
-
})
|
27
|
-
const service = new FullProcessorServiceImpl(baseService)
|
28
|
-
|
29
|
-
before(async () => {
|
30
|
-
await service.start({ templateInstances: [] }, TEST_CONTEXT)
|
31
|
-
})
|
32
|
-
|
33
|
-
test('Check transaction dispatch', async () => {
|
34
|
-
const binding1: DataBinding = {
|
35
|
-
data: {
|
36
|
-
raw: new Uint8Array(),
|
37
|
-
ethBlock: {
|
38
|
-
block: {
|
39
|
-
number: '0x1'
|
40
|
-
}
|
41
|
-
}
|
42
|
-
},
|
43
|
-
handlerType: HandlerType.UNKNOWN,
|
44
|
-
handlerIds: [0]
|
45
|
-
}
|
46
|
-
|
47
|
-
await service.processBindings({ bindings: [binding1] }, TEST_CONTEXT)
|
48
|
-
assert(testRequest.handlerType === HandlerType.UNKNOWN)
|
49
|
-
assert((testRequest.data?.raw.length || 0) > 0)
|
50
|
-
})
|
51
|
-
})
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { describe, test } from 'node:test'
|
2
|
-
import { assert } from 'chai'
|
3
|
-
import { State, MapStateStorage } from './state.js'
|
4
|
-
|
5
|
-
describe('state storage tests', () => {
|
6
|
-
State.reset()
|
7
|
-
|
8
|
-
test('test labels', async () => {
|
9
|
-
// assert(false)
|
10
|
-
class TestState extends MapStateStorage<any> {
|
11
|
-
static INSTANCE = new TestState()
|
12
|
-
}
|
13
|
-
const m = TestState.INSTANCE.getOrRegister()
|
14
|
-
assert(m !== undefined)
|
15
|
-
|
16
|
-
const v1 = TestState.INSTANCE.getOrSetValue('k1', {})
|
17
|
-
const v2 = TestState.INSTANCE.getOrSetValue('k1', { a: '' })
|
18
|
-
assert(v1 === v2)
|
19
|
-
TestState.INSTANCE.getOrSetValue('k2', 'v2')
|
20
|
-
|
21
|
-
assert(TestState.INSTANCE.getValues().length === 2)
|
22
|
-
assert(State.INSTANCE.stateMap.size === 1)
|
23
|
-
assert(State.INSTANCE.stateMap.keys().next().value === 'TestState')
|
24
|
-
})
|
25
|
-
})
|