The main goal of new KAPI release is preparing service for supporting multiple Staking Modules. Aside from [refactoring KAPI](https://hackmd.io/WZi57W_gR4-KUW_qzxwHSw?both) that will add support of modules we need to fix performance and memory consumption. Detailed about our suggestions around performance you can read [here](https://hackmd.io/PqnOq79YQkWjKLk4y2G3fA?both).
At the same time we want to improve current implementation.
In this document we want to explain why we decided not to change structure of database and didn't get rid of transactions.
## Assumptions and facts we based on
- Staking modules' keys, operators and meta should be stored for the same execution layer state (blockNumber, blockHash, timestamp); Update also should be an atomic operation;
- Api responses should contain data that was get from storage for the same execution layer state (blockNumber, blockHash, timestamp);
- Should be launched only one KAPI instance at once that use the same db; only KAPI can change data in db;
- Current version stores only one version of keys;
## What isolation level we use in KAPI?
We need to update keys of all modules in the same "update job" launch. Also we need to prevent concurrency in writing keys, operators and meta by different "update job" launches. For the second problem we use decorator `@OneAtTime()` that prevents already running jobs from starting.
For the first problem we use transactions. For update `READ_COMMITTED` level is enough. It doesn't stop other transactions from updating the same data (but we have `@OneAtTime()` decorator). But it gives us atomicity. If something will be wrong during update, all changes will be rollbacked.
For making responses on user requests this level of isolation is not enough as we run few `select` commands at the same endpoint and `update` command can happen between two `select`. But hopefully postgres implements `REPEATABLE READ` level that can use the same data snapshot during transaction execution.
Since all results described in [document](https://hackmd.io/PqnOq79YQkWjKLk4y2G3fA?both) were achived with the preservation of transactions, we decided that changing the way we store data in the database to get rid of transactions is not needed at the moment. Possibly in the next iteration we will consider a more elegant or efficient approach for storing data.
## Questions we want to explore in more depth
- When does MikroOrm initiate connect to postgresql?
- If connection was closed, how mikrorm re-establish it?
- We noticed that in current KAPI version on prod we get `Knex: Timeout acquiring a connection` error , if memory consumption reaches node limit
```
{
"context": "ExceptionsHandler",
"level": "error",
"message": "Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?",
"stack": [
"KnexTimeoutError: Knex: Timeout acquiring a connection. The pool is probably full. Are you missing a .transacting(trx) call?\n at Client_PG.acquireConnection (/app/node_modules/knex/lib/client.js:307:26)\n at async Transaction_PG.acquireConnection (/app/node_modules/knex/lib/execution/transaction.js:250:28)"
]
}
```
## Other ideas
### Versioning?
### Place for your ideas
## исследование repeatable read
Тест на ветке develop
перед запуском КАПИ меняю мету
```sql
~
kapi=# UPDATE "registry_meta" SET "keys_op_index" = 16, "block_number"= 7;
тест на тестнете провожу
в методе который будет в эндпоинте вызываться засыпаю после ключей на 2 минуты
```typescript=
public async getKeysWithMeta(filters: KeysFilter): Promise<{ keys: RegistryKey[]; meta: RegistryMeta | null }> {
const { keys, meta } = await this.entityManager.transactional(
async () => {
const where = {};
if (filters.operatorIndex != undefined) {
where['operatorIndex'] = filters.operatorIndex;
}
if (filters.used != undefined) {
where['used'] = filters.used;
}
const keys = await this.keyStorageService.find(where);
console.log('haha');
await this.sleep(120000);
const meta = await this.getMetaDataFromStorage();
return { keys, meta };
},
{ isolationLevel: IsolationLevel.REPEATABLE_READ },
);
return { keys, meta };
}
```
Запускаю сервис , жду пока запуститься джоба, она должна будет все данные обновить (дополнительно в app.module debug: true у mikro orm)
Делаю запрос curl "http://localhost:3000/v1/keys?operatorIndex=1&used=false"
проверяю уровень изоляции
[query] begin isolation level repeatable read
[query] select "r0".* from "registry_key" as "r0" where "r0"."operator_index" = 1 and "r0"."used" = false [took 5 ms]
haha
ожидаю от теста: ?
если мета изменится , то получается repeatable_read НЕ защищает нас от commit другой транзакции
если не изменится , то получается repeatable_read Защищает нас от commit другой транзакции (нужно получается другие эндпоинты проверить)
часть результата
{"key":"0x9538f0af0ac73b8cbac4083cedb468ba11a62310cab8ecd759a16486069bc7af8c6edcae1cabe860ce2444fbe6c0bc73",
"depositSignature":"0x8aaaa1c4ddcf6180d1faf6c233155a07a1e885848f57de1a0b7e0f62401f63f7f089068bd73771ed42dc7f5a73e52e1b1244787344397b83a2cf943233d17927f149f93c7d7981da122241171c19a90d6101b412edcd06cc42af1c75f1d685d3",
"operatorIndex":1,"used":false,"moduleAddress":"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320"}],
"meta":{"elBlockSnapshot":
{"blockNumber":7,"blockHash":"0x5e0da48e5bef051429d5dd786b1e0997ac38f51b3e99143e4bad6968183cfacb","timestamp":1689350760}}}
получается мета не поменялась -> то получается repeatable_read Защищает нас от commit другой транзакци
Тест2
почти такой же
удалила все таблицы и убрала too early response из эндпоинта
```psql=
kapi=# \d
Did not find any relations.
```
```typescript=
async get(filters: KeyQuery) {
// Promise<KeyListResponse> {
const stakingModules = await this.keysUpdateService.getStakingModules();
if (stakingModules.length === 0) {
this.logger.warn('No staking modules in list. Maybe didnt fetched from SR yet');
throw httpExceptionTooEarlyResp();
}
// keys could be of type CuratedKey | CommunityKey
const collectedKeys: KeyWithModuleAddress[][] = [];
let elBlockSnapshot: ELBlockSnapshot | null = null;
// Because of current lido-nestjs/registry implementation in case of more than one
// staking router module we need to wrap code below in transaction (with serializable isolation level that is default in mikro orm )
// to prevent reading keys for different blocks
// But now we have only one module and in current future we will try to find solution without transactions
// TODO: rewrite to "for of" after refactoring to stakingRouterModule
for (let i = 0; i < stakingModules.length; i++) {
if (stakingModules[i].type == STAKING_MODULE_TYPE.CURATED_ONCHAIN_V1_TYPE) {
// If some of modules has null meta, it means update hasnt been finished
const { keys: curatedKeys, meta } = await this.curatedService.getKeysWithMeta({
used: filters.used,
operatorIndex: filters.operatorIndex,
});
if (!meta) {
this.logger.warn(`Meta is null, maybe data hasn't been written in db yet.!!!!!`);
// throw httpExceptionTooEarlyResp();
return { data: [], meta: {} };
}
const keysWithAddress: KeyWithModuleAddress[] = curatedKeys.map(
(key) => new KeyWithModuleAddress(key, stakingModules[i].stakingModuleAddress),
);
// meta should be the same for all modules
// so in answer we can use meta of any module
// lets use meta of first module in list
// currently we sure if stakingModules is not empty, we will have in list Curated Module
// in future this check should be in each if clause
if (i === 0) {
elBlockSnapshot = new ELBlockSnapshot(meta);
}
collectedKeys.push(keysWithAddress);
}
}
// we check stakingModules list types so this condition should never be true
if (!elBlockSnapshot) {
this.logger.warn(`Meta for response wasnt set.`);
throw httpExceptionTooEarlyResp();
}
return {
data: collectedKeys.flat(),
meta: {
elBlockSnapshot,
},
};
}
```
Оставила слип
```typescript=
public async getKeysWithMeta(filters: KeysFilter): Promise<{ keys: RegistryKey[]; meta: RegistryMeta | null }> {
const { keys, meta } = await this.entityManager.transactional(
async () => {
const where = {};
if (filters.operatorIndex != undefined) {
where['operatorIndex'] = filters.operatorIndex;
}
if (filters.used != undefined) {
where['used'] = filters.used;
}
const keys = await this.keyStorageService.find(where);
console.log('sleeeeep');
await this.sleep(120000);
const meta = await this.getMetaDataFromStorage();
return { keys, meta };
},
{ isolationLevel: IsolationLevel.REPEATABLE_READ },
);
return { keys, meta };
}
```
Запускаю приложение
Делаю запрос после 120 секунд ожидания получаю ответ
curl "http://localhost:3000/v1/keys?operatorIndex=1&used=false"
{"data":[],"meta":{}}
Log (ключи обновились и мета тоже):
Можно найти строку Query {"method":"GET","originalUrl":"/v1/keys?operatorIndex=1&used=false","statusCode":200,"userAgent":"curl/7.87.0","ip":"127.0.0.1"}
и увидетль что мета обновила, ключи тоже, время когда завершился запрос и что мета пустая , те транзакция работает (ветка https://github.com/lidofinance/lido-keys-api/tree/test-repeatable-read)
```txt
[8:33:45 PM] Starting compilation in watch mode...
DeprecationWarning: 'getMutableClone' has been deprecated since v4.0.0. Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`.
DeprecationWarning: 'createLiteral' has been deprecated since v4.0.0. Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead.
[8:33:47 PM] Found 0 errors. Watching for file changes.
Found [3] DB migration files.
Processing 'Migration20220225153937'
Applied 'Migration20220225153937'
Processing 'Migration20221225154138'
Applied 'Migration20221225154138'
Processing 'Migration20230119153937'
Applied 'Migration20230119153937'
2023-07-14 20:33:49 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:33:49 info: Init app {"env":"development","name":"lido-keys-api","version":"0.8.0"}
(node:8166) [FST_MODULE_DEP_FASTIFY-FORMBODY] FastifyWarning.fastify-formbody: fastify-formbody has been deprecated. Use @fastify/formbody@6.0.0 instead.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8166) [FST_MODULE_DEP_FASTIFY-STATIC] FastifyWarning.fastify-static: fastify-static has been deprecated. Use @fastify/static@5.0.0 instead.
2023-07-14 20:33:49 info: Starting Nest application... "NestFactory"
2023-07-14 20:33:49 info: PrometheusModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: LoggerModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConsensusProviderModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: MikroOrmModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: LoggerModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: PrometheusModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConfigHostModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: TerminusModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConfigModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: MiddlewareModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: DiscoveryModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConfigModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: HealthModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ScheduleModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConsensusFetchModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: CacheModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ThrottlerModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: WinstonModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ConsensusModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: FallbackProviderModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: IStakingModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ExecutionProviderModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: HTTPModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: AppModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: StorageModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: JobModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: MikroOrmCoreModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: MikroOrmModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: MikroOrmModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ValidatorsRegistryModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: RegistryStorageModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ValidatorsModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: ValidatorsUpdateModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: LidoLocatorContractModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: LidoContractModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: RegistryContractModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: LidoLocatorModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: RegistryFetchModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: StakingRouterFetchModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: KeyRegistryModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: StakingRouterModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: KeysUpdateModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: StatusModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: JobsModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: KeysModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: SRModulesModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: SRModulesKeysModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: SRModulesValidatorsModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: SRModulesOperatorsModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: SRModulesOperatorsKeysModule dependencies initialized "InstanceLoader"
2023-07-14 20:33:49 info: HealthController {/health}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/health, GET} route "RouterExplorer"
2023-07-14 20:33:49 info: PrometheusController {/metrics}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/metrics, GET} route "RouterExplorer"
2023-07-14 20:33:49 info: KeysController {/keys}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/keys, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/keys/:pubkey, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/keys/find, POST} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: SRModulesController {/modules}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/modules, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: SRModulesKeysController {/modules}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/modules/keys, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/keys, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/keys/find, POST} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: SRModulesValidatorsController {/modules}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/validators/validator-exits-to-prepare/:operator_id, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/validators/generate-unsigned-exit-messages/:operator_id, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: SRModulesOperatorsController {/}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/operators, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/operators, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/operators/:operator_id, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: SRModulesOperatorsKeysController {/modules}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/modules/:module_id/operators/keys, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: StatusController {/status}: "RoutesResolver"
2023-07-14 20:33:49 info: Mapped {/status, GET} (version: 1) route "RouterExplorer"
2023-07-14 20:33:49 info: Nest application successfully started "NestApplication"
2023-07-14 20:33:49 info: Listening on 3000
2023-07-14 20:33:49 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:33:52 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:33:54 info: Fetched 1 modules
2023-07-14 20:33:54 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:33:54 info: Start updating curated keys
2023-07-14 20:33:56 info: Collected metadata {"prevMeta":null,"currMeta":{"blockNumber":9345258,"blockHash":"0x9cc39aca4d01752cd07ddb75d82e4509754bdde3cc4bf5924e42161ec57d3330","keysOpIndex":3214,"timestamp":1689352428}}
2023-07-14 20:33:58 info: Collected operators {"previousOperators":0,"currentOperators":78}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":0,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":2,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":3,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":5,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":13,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":14,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":19,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":20,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":21,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":22,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":31,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":33,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":62,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:58 info: Keys fetched {"operatorIndex":76,"fromIndex":0,"toIndex":0,"fetchedKeys":0}
2023-07-14 20:33:59 info: Keys fetched {"operatorIndex":4,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":9,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":7,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":8,"fromIndex":0,"toIndex":109,"fetchedKeys":109}
sleeep
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":11,"fromIndex":0,"toIndex":110,"fetchedKeys":110}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":12,"fromIndex":0,"toIndex":41,"fetchedKeys":41}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":15,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":16,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":17,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:00 info: Keys fetched {"operatorIndex":18,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":1,"fromIndex":0,"toIndex":123,"fetchedKeys":123}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":36,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":37,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":38,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":39,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":40,"fromIndex":0,"toIndex":12,"fetchedKeys":12}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":29,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":30,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":32,"fromIndex":0,"toIndex":2,"fetchedKeys":2}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":34,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":35,"fromIndex":0,"toIndex":160,"fetchedKeys":160}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":23,"fromIndex":0,"toIndex":54,"fetchedKeys":54}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":24,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":25,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":26,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":27,"fromIndex":0,"toIndex":22,"fetchedKeys":22}
2023-07-14 20:34:01 info: Keys fetched {"operatorIndex":28,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":43,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":44,"fromIndex":0,"toIndex":20,"fetchedKeys":20}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":45,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":47,"fromIndex":0,"toIndex":1,"fetchedKeys":1}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":48,"fromIndex":0,"toIndex":1,"fetchedKeys":1}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":49,"fromIndex":0,"toIndex":1,"fetchedKeys":1}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":50,"fromIndex":0,"toIndex":1,"fetchedKeys":1}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":51,"fromIndex":0,"toIndex":70,"fetchedKeys":70}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":52,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":53,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":54,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:03 info: Keys fetched {"operatorIndex":55,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":56,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":57,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":58,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":59,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":60,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:04 info: Keys fetched {"operatorIndex":61,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":68,"fromIndex":0,"toIndex":1,"fetchedKeys":1}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":69,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":70,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":71,"fromIndex":0,"toIndex":10,"fetchedKeys":10}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":72,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":73,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":74,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":75,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:06 info: Keys fetched {"operatorIndex":77,"fromIndex":0,"toIndex":5,"fetchedKeys":5}
2023-07-14 20:34:09 info: Keys fetched {"operatorIndex":10,"fromIndex":0,"toIndex":310,"fetchedKeys":310}
2023-07-14 20:34:15 info: Keys fetched {"operatorIndex":46,"fromIndex":0,"toIndex":500,"fetchedKeys":500}
2023-07-14 20:34:27 info: Keys fetched {"operatorIndex":42,"fromIndex":0,"toIndex":1010,"fetchedKeys":1010}
2023-07-14 20:34:40 info: Keys fetched {"operatorIndex":41,"fromIndex":0,"toIndex":2000,"fetchedKeys":2000}
2023-07-14 20:34:41 info: Keys fetched {"operatorIndex":63,"fromIndex":0,"toIndex":2000,"fetchedKeys":2000}
2023-07-14 20:34:43 info: Keys fetched {"operatorIndex":67,"fromIndex":0,"toIndex":2000,"fetchedKeys":2000}
2023-07-14 20:34:45 info: Keys fetched {"operatorIndex":66,"fromIndex":0,"toIndex":2000,"fetchedKeys":2000}
2023-07-14 20:34:49 info: Keys fetched {"operatorIndex":6,"fromIndex":0,"toIndex":2511,"fetchedKeys":2511}
2023-07-14 20:34:51 info: Keys fetched {"operatorIndex":64,"fromIndex":0,"toIndex":3000,"fetchedKeys":3000}
2023-07-14 20:34:51 info: Keys fetched {"operatorIndex":65,"fromIndex":0,"toIndex":3000,"fetchedKeys":3000}
2023-07-14 20:34:51 info: Fetched updated keys {"updatedKeys":19404}
2023-07-14 20:34:52 info: Saved data to the DB {"operators":78,"updatedKeys":19404,"currMeta":{"blockNumber":9345258,"blockHash":"0x9cc39aca4d01752cd07ddb75d82e4509754bdde3cc4bf5924e42161ec57d3330","keysOpIndex":3214,"timestamp":1689352428}}
2023-07-14 20:34:52 info: Curated Module metrics updated
2023-07-14 20:34:52 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:34:52 info: Finished KeysUpdateService initialization
2023-07-14 20:34:52 info: Job for updating validators is disabled
2023-07-14 20:34:57 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:01 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:01 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:02 info: Fetched 1 modules
2023-07-14 20:35:02 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:02 info: Start updating curated keys
2023-07-14 20:35:02 info: Already running updateKeys {"propertyName":"updateKeys","executing":true,"timeExecuting":5}
2023-07-14 20:35:06 info: Collected metadata {"prevMeta":{"blockNumber":9345258,"blockHash":"0x9cc39aca4d01752cd07ddb75d82e4509754bdde3cc4bf5924e42161ec57d3330","keysOpIndex":3214,"timestamp":1689352428},"currMeta":{"blockNumber":9345261,"blockHash":"0xeb8ba6433657cc7d68f1cd88d3db7ebdbf6a93e04bdbd4ce321b6b75928b751f","keysOpIndex":3214,"timestamp":1689352476}}
2023-07-14 20:35:06 debug: Same state, no data update required {"currMeta":{"blockNumber":9345261,"blockHash":"0xeb8ba6433657cc7d68f1cd88d3db7ebdbf6a93e04bdbd4ce321b6b75928b751f","keysOpIndex":3214,"timestamp":1689352476}}
2023-07-14 20:35:06 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345261,"blockHash":"0xeb8ba6433657cc7d68f1cd88d3db7ebdbf6a93e04bdbd4ce321b6b75928b751f","keysOpIndex":3214,"timestamp":1689352476}}
2023-07-14 20:35:06 info: Curated Module metrics updated
2023-07-14 20:35:06 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:07 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:08 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:08 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:09 info: Fetched 1 modules
2023-07-14 20:35:09 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:09 info: Start updating curated keys
2023-07-14 20:35:10 info: Collected metadata {"prevMeta":{"blockNumber":9345261,"blockHash":"0xeb8ba6433657cc7d68f1cd88d3db7ebdbf6a93e04bdbd4ce321b6b75928b751f","keysOpIndex":3214,"timestamp":1689352476},"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:10 debug: Same state, no data update required {"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:10 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:10 info: Curated Module metrics updated
2023-07-14 20:35:10 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:12 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:13 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:13 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:14 info: Fetched 1 modules
2023-07-14 20:35:14 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:14 info: Start updating curated keys
2023-07-14 20:35:14 info: Collected metadata {"prevMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500},"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:14 debug: Same state, no data update required {"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:14 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500}}
2023-07-14 20:35:14 info: Curated Module metrics updated
2023-07-14 20:35:14 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:17 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:18 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:18 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:19 info: Fetched 1 modules
2023-07-14 20:35:19 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:19 info: Start updating curated keys
2023-07-14 20:35:19 info: Collected metadata {"prevMeta":{"blockNumber":9345262,"blockHash":"0x6820488b6c679d9717f5376467895b8238371839e2d798798db335154b9932a6","keysOpIndex":3214,"timestamp":1689352500},"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:19 debug: Same state, no data update required {"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:19 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:19 info: Curated Module metrics updated
2023-07-14 20:35:19 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:22 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:24 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:24 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:25 info: Fetched 1 modules
2023-07-14 20:35:25 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:25 info: Start updating curated keys
2023-07-14 20:35:27 info: Collected metadata {"prevMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512},"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:27 debug: Same state, no data update required {"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:27 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512}}
2023-07-14 20:35:27 info: Curated Module metrics updated
2023-07-14 20:35:27 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:27 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:28 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:28 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:30 info: Fetched 1 modules
2023-07-14 20:35:30 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:30 info: Start updating curated keys
2023-07-14 20:35:31 info: Collected metadata {"prevMeta":{"blockNumber":9345263,"blockHash":"0x998b47ccafe0f871a2cea4a0811ecc59459bcbd31377ea866188cf30a5019378","keysOpIndex":3214,"timestamp":1689352512},"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:31 debug: Same state, no data update required {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:31 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:31 info: Curated Module metrics updated
2023-07-14 20:35:31 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:32 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:33 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:34 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:34 info: Fetched 1 modules
2023-07-14 20:35:34 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:34 info: Start updating curated keys
2023-07-14 20:35:35 info: Collected metadata {"prevMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524},"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:35 debug: Same state, no data update required {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:35 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:35 info: Curated Module metrics updated
2023-07-14 20:35:35 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:37 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:38 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:39 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:39 info: Fetched 1 modules
2023-07-14 20:35:39 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:39 info: Start updating curated keys
2023-07-14 20:35:40 info: Collected metadata {"prevMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524},"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:40 debug: Same state, no data update required {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:40 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:40 info: Curated Module metrics updated
2023-07-14 20:35:40 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:42 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:43 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:43 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:44 info: Fetched 1 modules
2023-07-14 20:35:44 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:44 info: Start updating curated keys
2023-07-14 20:35:45 info: Collected metadata {"prevMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524},"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:45 debug: Same state, no data update required {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:45 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:45 info: Curated Module metrics updated
2023-07-14 20:35:45 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:47 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:48 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:49 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:49 info: Fetched 1 modules
2023-07-14 20:35:49 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:49 info: Start updating curated keys
2023-07-14 20:35:50 info: Collected metadata {"prevMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524},"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:50 debug: Same state, no data update required {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:50 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524}}
2023-07-14 20:35:50 info: Curated Module metrics updated
2023-07-14 20:35:50 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:52 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:53 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:53 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:54 info: Fetched 1 modules
2023-07-14 20:35:54 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:54 info: Start updating curated keys
2023-07-14 20:35:55 info: Collected metadata {"prevMeta":{"blockNumber":9345264,"blockHash":"0x0ebeb47727355aafad95f29f7307e4173f2639ee8115287a1cf3be7a8afd43eb","keysOpIndex":3214,"timestamp":1689352524},"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:35:55 debug: Same state, no data update required {"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:35:55 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:35:55 info: Curated Module metrics updated
2023-07-14 20:35:55 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:57 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:35:58 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:35:58 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:35:59 info: Fetched 1 modules
2023-07-14 20:35:59 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:35:59 info: Start updating curated keys
2023-07-14 20:36:00 info: Collected metadata {"prevMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548},"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:36:00 debug: Same state, no data update required {"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:36:00 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548}}
2023-07-14 20:36:00 info: Curated Module metrics updated
2023-07-14 20:36:00 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:00 warn: Meta is null, maybe data hasn't been written in db yet.!!!!!
2023-07-14 20:36:00 info: Query {"method":"GET","originalUrl":"/v1/keys?operatorIndex=1&used=false","statusCode":200,"userAgent":"curl/7.87.0","ip":"127.0.0.1"}
2023-07-14 20:36:02 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:03 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:36:04 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:36:04 info: Fetched 1 modules
2023-07-14 20:36:04 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:36:04 info: Start updating curated keys
2023-07-14 20:36:05 info: Collected metadata {"prevMeta":{"blockNumber":9345265,"blockHash":"0x81a21b382e932c40d4a3e7a8d681e4dfb592bdb03c66b70bc886cea2cf0bc083","keysOpIndex":3214,"timestamp":1689352548},"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:05 debug: Same state, no data update required {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:05 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:05 info: Curated Module metrics updated
2023-07-14 20:36:05 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:07 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:08 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:36:08 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:36:09 info: Fetched 1 modules
2023-07-14 20:36:09 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:36:09 info: Start updating curated keys
2023-07-14 20:36:10 info: Collected metadata {"prevMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560},"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:10 debug: Same state, no data update required {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:10 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:10 info: Curated Module metrics updated
2023-07-14 20:36:10 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:12 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:13 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:36:13 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:36:14 info: Fetched 1 modules
2023-07-14 20:36:14 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:36:14 info: Start updating curated keys
2023-07-14 20:36:15 info: Collected metadata {"prevMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560},"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:15 debug: Same state, no data update required {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:15 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:15 info: Curated Module metrics updated
2023-07-14 20:36:15 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:17 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:18 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:36:18 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:36:19 info: Fetched 1 modules
2023-07-14 20:36:19 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:36:19 info: Start updating curated keys
2023-07-14 20:36:20 info: Collected metadata {"prevMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560},"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:20 debug: Same state, no data update required {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:20 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:20 info: Curated Module metrics updated
2023-07-14 20:36:20 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:22 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-14 20:36:23 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-14 20:36:23 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-14 20:36:24 info: Fetched 1 modules
2023-07-14 20:36:24 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b17214"},{"type":"BigNumber","hex":"0x8e987e"},{"type":"BigNumber","hex":"0x05a8"}]]
2023-07-14 20:36:24 info: Start updating curated keys
2023-07-14 20:36:25 info: Collected metadata {"prevMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560},"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:25 debug: Same state, no data update required {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:25 debug: Updated metadata in the DB {"currMeta":{"blockNumber":9345266,"blockHash":"0x91b43dc8d93c6a7217efc25e6d7366fa552e8d64007c599d34c7a9eb3a2f43fc","keysOpIndex":3214,"timestamp":1689352560}}
2023-07-14 20:36:25 info: Curated Module metrics updated
2023-07-14 20:36:25 info: Job ended {"name":"Update Staking Router Modules keys"}
^CJobs Service on module destroy
```
Тест 3
Провожу тест на ветке develop
меняю код чтения данных из бд, sleep ставлю до запроса ключей и меты
```typescript
public async getKeysWithMeta(filters: KeysFilter): Promise<{ keys: RegistryKey[]; meta: RegistryMeta | null }> {
const { keys, meta } = await this.entityManager.transactional(
async () => {
const where = {};
if (filters.operatorIndex != undefined) {
where['operatorIndex'] = filters.operatorIndex;
}
if (filters.used != undefined) {
where['used'] = filters.used;
}
console.log('sleeep');
await this.sleep(120000);
const keys = await this.keyStorageService.find(where);
const meta = await this.getMetaDataFromStorage();
return { keys, meta };
},
{ isolationLevel: IsolationLevel.REPEATABLE_READ },
);
return { keys, meta };
}
```
удаляю все из бд
запускаю приложение
Делаю запрос curl "http://localhost:3000/v1/keys"
в запросе получаю обновленные данные
потому что repeatable_read делает снапшот на момент первого запроса в транзе
// те все, что было закоммичено до const keys = await this.keyStorageService.find(where); в коде выше будет видно в транзе
возможно именно что-то такое происходит в новом коде
Test 4 уже на новом коде
проверяю гипотезу выше
Из лога видно, что границы транзы определяются не верно
commit происходит раньше , чем начинаем читать ключи
```
r","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:06:50 info: Job ended {"name":"Update Staking Router Modules keys"}
[query] begin isolation level serializable
TADAAAA!
2023-07-16 13:06:54 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:06:55 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:06:55 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:06:55 info: Fetched 1 modules
2023-07-16 13:06:55 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:06:55 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-16 13:06:59 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:00 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:07:00 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:07:00 info: Fetched 1 modules
2023-07-16 13:07:00 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:07:00 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:04 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:05 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:07:05 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:07:05 info: Fetched 1 modules
2023-07-16 13:07:05 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:07:05 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:09 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:10 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:07:10 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:07:10 info: Fetched 1 modules
2023-07-16 13:07:10 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:07:10 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:14 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:15 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:07:15 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:07:15 info: Fetched 1 modules
2023-07-16 13:07:15 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:07:15 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:19 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-16 13:07:20 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-16 13:07:20 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-16 13:07:20 info: Fetched 1 modules
2023-07-16 13:07:20 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b3a680"},{"type":"BigNumber","hex":"0x8ebc3c"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-16 13:07:20 info: Job ended {"name":"Update Staking Router Modules keys"}
[query] select "r0".* from "registry_meta" as "r0" order by "r0"."block_number" desc limit 1 [took 4 ms]
[query] commit
[query] select "r0".* from "registry_key" as "r0" where "r0"."operator_index" = 1 and "r0"."used" = true limit 10000 [took 1 ms]
```
В коде выше заменила метод с генератором
(const keysStream = await is.keyStorageService.fetchKeysByChunks(where, {});
) на обычный метод, который читает все ключи из бд
const keysStream = await this.keyStorageService.findAll();
в логе вижу коммит в ожидаемый момент и меняя block_number=5 меты на block_number=6 после
[query] select "r0".* from "registry_key" as "r0" order by "r0"."operator_index" asc, "r0"."index" asc [took 2 ms]
получаю в ответе block_number=5 как и ожидала, получается дето в границах транзакции и с генератором их сложно установить
```
query] begin isolation level serializable
TADAAAA!
[query] select "r0".* from "registry_key" as "r0" order by "r0"."operator_index" asc, "r0"."index" asc [took 2 ms]
2023-07-17 00:00:51 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:00:51 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:00:52 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:00:52 info: Fetched 1 modules
2023-07-17 00:00:52 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:00:52 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 00:00:56 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:00:56 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:00:57 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:00:57 info: Fetched 1 modules
2023-07-17 00:00:57 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:00:57 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:01 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:01 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:01:02 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:01:02 info: Fetched 1 modules
2023-07-17 00:01:02 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:01:02 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:06 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:06 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:01:07 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:01:07 info: Fetched 1 modules
2023-07-17 00:01:07 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:01:07 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:11 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:11 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:01:12 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:01:12 info: Fetched 1 modules
2023-07-17 00:01:12 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:01:12 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:16 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 00:01:16 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 00:01:17 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 00:01:17 info: Fetched 1 modules
2023-07-17 00:01:17 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b4452c"},{"type":"BigNumber","hex":"0x8ec5e4"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 00:01:17 info: Job ended {"name":"Update Staking Router Modules keys"}
[query] select "r0".* from "registry_meta" as "r0" order by "r0"."block_number" desc limit 1 [took 4 ms]
[query] commit
Дело раскрыто
скорее всего раньше у меня не проходил тест, так как я меняла мету раньше чем выполнялся первая non-transaction-control команда внутри транзакции (This level is different from Read Committed in that a query in a repeatable read transaction sees a snapshot as of the start of the first non-transaction-control statement in the transaction, not as of the start of the current statement within the transaction. Thus, successive SELECT commands within a single transaction see the same data, i.e., they do not see changes made by other transactions that committed after their own transaction started.)
Плюс границы транзакции из-за функции-генератора вынести нужно выше в контроллер
из лога видно что границы нормально определены , коммит после всех операций
после того, как увидела в логе первый non-transaction-control , обновила мету , в запросе получила старое значение меты как и должна была
``` typescript=
async get(@Query() filters: KeyQuery, @Res() reply: FastifyReply) {
await this.entityManager.transactional(
async () => {
const { keysStream, meta } = await this.keysService.get(filters);
const jsonStream = JSONStream.stringify('{ "meta": ' + JSON.stringify(meta) + ', "keys": [', ',', ']}');
// Передаем стрим в качестве ответа
reply.type('application/json').send(jsonStream);
// Наполняем стрим данными
// jsonStream.write(['meta', { meta: 1 }]);
for await (const keysBatch of keysStream) {
jsonStream.write(keysBatch);
}
jsonStream.end();
},
{ isolationLevel: IsolationLevel.REPEATABLE_READ },
);
}
```
```
2023-07-17 01:12:49 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b452e8"},{"type":"BigNumber","hex":"0x8ec6c0"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 01:12:49 info: Job ended {"name":"Update Staking Router Modules keys"}
[query] begin isolation level repeatable read
[query] select "r0".* from "registry_meta" as "r0" order by "r0"."block_number" desc limit 1 [took 2 ms]
2023-07-17 01:12:52 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 01:12:52 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 01:12:52 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 01:12:53 info: Fetched 1 modules
2023-07-17 01:12:53 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b452e8"},{"type":"BigNumber","hex":"0x8ec6c0"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 01:12:53 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 01:12:57 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 01:12:57 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 01:12:57 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 01:12:58 info: Fetched 1 modules
2023-07-17 01:12:58 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b452e8"},{"type":"BigNumber","hex":"0x8ec6c0"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 01:12:58 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 01:13:02 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 01:13:02 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 01:13:02 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 01:13:03 info: Fetched 1 modules
2023-07-17 01:13:03 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b452e8"},{"type":"BigNumber","hex":"0x8ec6c0"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 01:13:03 info: Job ended {"name":"Update Staking Router Modules keys"}
2023-07-17 01:13:07 info: Job started {"name":"Update Staking Router Modules keys"}
2023-07-17 01:13:07 info: Contract locator address "0x1eDf09b5023DC86737b59dE68a8130De878984f5"
2023-07-17 01:13:07 info: Staking router module address "0xa3Dbd317E53D363176359E10948BA0b1c0A4c820"
2023-07-17 01:13:08 info: Fetched 1 modules
2023-07-17 01:13:08 info: Staking modules [[1,"0x9D4AF1Ee19Dad8857db3a45B0374c81c8A1C6320",500,500,10000,0,"curated-onchain-v1",{"type":"BigNumber","hex":"0x64b452e8"},{"type":"BigNumber","hex":"0x8ec6c0"},{"type":"BigNumber","hex":"0x05a9"}]]
2023-07-17 01:13:08 info: Job ended {"name":"Update Staking Router Modules keys"}
[query] select "r0".* from "registry_key" as "r0" where "r0"."operator_index" = 1 and "r0"."used" = true limit 10000 [took 3 ms]
[query] commit
2023-07-17 01:13:09 info: Query {"method":"GET","originalUrl":"/v1/keys/stream/?used=true&operatorIndex=1","statusCode":200,"userAgent":"curl/7.87.0","ip":"127.0.0.1"}
```
<!-- ---
У нас есть две таблицы:
мета и ключи
что произойдет, когда мы читаем в первую очередь мету, а между чтением ключей и меты и ставим слип изменяем ключи? -->
тест 5
обновили ключ во время запроса , в ответе получили данные до обновления
```typescript
public async getKeysWithMetaStream(filters: KeysFilter): Promise<any> {
const where = {};
if (filters.operatorIndex != undefined) {
where['operatorIndex'] = filters.operatorIndex;
}
if (filters.used != undefined) {
where['used'] = filters.used;
}
const meta = await this.getMetaDataFromStorage();
await this.sleep(30000);
const keysStream = await this.keyStorageService.fetchKeysByChunks(where, {});
return { keysStream, meta };
}
```