Closed bogdanS98 closed 4 weeks ago
@pendulum-chain/devs can we please review this? it would unblock the nabla testnet campaign
Good catch @ebma! @bogdanS98 you need to be careful to cleanly distinguish addresses encoded in hex and ss58 format. Both are of type string
, so TypeScript doesn't help. You will see that I tried to always add the postfix hexAddress
or ss58Address
to variable names (e.g. here) to at least track it using the name.
Note:
@pendulum-chain/devs any update on this? is there a fix to be done, can we please priortize this as this is blocking the campaign
@pendulum-chain/devs any update on this? is there a fix to be done, can we please priortize this as this is blocking the campaign
I'm working on this as we speak, will push the latest changes requested in the next few hours
I'm working on this as we speak, will push the latest changes requested in the next few hours
Thank you Bogdan for the update
I would expect the sender to have a properly encoded address so that I can easily look up the account on chain. This is not the case at the moment.
I also get quite a lot of errors when processing on Foucoco locally. Any ideas @bogdanS98?
18:08:08 INFO sqd:processor 1508390 / 1562149, rate: 1449 blocks/sec, mapping: 939 blocks/sec, 1681 items/sec, eta: 37s Error processing event 'Contracts.ContractEmitted'. Skipping due to error: QueryFailedError: update or delete on table "nabla_swap_fee" violates foreign key constraint "FK_dd24afed240ad46290bfcf0603b" on table "nabla_swap" at PostgresQueryRunner.query (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async DeleteQueryBuilder.execute (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/DeleteQueryBuilder.js:52:33) at async Store.remove (/Users/marcel/Documents/pendulum-squids/node_modules/@subsquid/typeorm-store/lib/store.js:114:17) at async filterSwapFeeHistory (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/swapPoolEventHandler.js:118:13) at async updateAndPruneSwapFeeHistory (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/swapPoolEventHandler.js:112:5) at async updateAprAfterSwap (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/swapPoolEventHandler.js:124:5) at async handleChargedSwapFees (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/swapPoolEventHandler.js:68:5) at async handleSwapPoolEvent (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/swapPoolEventHandler.js:23:13) at async handleContractEvent (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/handleEvent.js:71:13) { query: 'DELETE FROM "nabla_swap_fee" WHERE "id" IN ($1)', parameters: [ '1495223-3' ], driverError: error: update or delete on table "nabla_swap_fee" violates foreign key constraint "FK_dd24afed240ad46290bfcf0603b" on table "nabla_swap" at Parser.parseErrorMessage (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:287:98) at Parser.handlePacket (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:39:38) at Socket.<anonymous> (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/index.js:11:42) at Socket.emit (node:events:512:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { length: 317, severity: 'ERROR', code: '23503', detail: 'Key (id)=(1495223-3) is still referenced from table "nabla_swap".', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'nabla_swap', column: undefined, dataType: undefined, constraint: 'FK_dd24afed240ad46290bfcf0603b', file: 'ri_triggers.c', line: '2609', routine: 'ri_ReportViolation' }, length: 317, severity: 'ERROR', code: '23503', detail: 'Key (id)=(1495223-3) is still referenced from table "nabla_swap".', hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: 'public', table: 'nabla_swap', column: undefined, dataType: undefined, constraint: 'FK_dd24afed240ad46290bfcf0603b', file: 'ri_triggers.c', line: '2609', routine: 'ri_ReportViolation' } Error processing event 'Tokens.Transfer'. Skipping due to error: QueryFailedError: current transaction is aborted, commands ignored until end of transaction block at PostgresQueryRunner.query (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async InsertQueryBuilder.execute (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33) at async Store.upsert (/Users/marcel/Documents/pendulum-squids/node_modules/@subsquid/typeorm-store/lib/store.js:38:13) at async handleTokenTransfer (/Users/marcel/Documents/pendulum-squids/lib/mappings/token.js:329:5) at async /Users/marcel/Documents/pendulum-squids/lib/processor.js:130:25 at async TypeormDatabase.performUpdates (/Users/marcel/Documents/pendulum-squids/node_modules/@subsquid/typeorm-store/lib/database.js:139:13) at async /Users/marcel/Documents/pendulum-squids/node_modules/@subsquid/typeorm-store/lib/database.js:84:13 at async EntityManager.transaction (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/entity-manager/EntityManager.js:73:28) at async TypeormDatabase.submit (/Users/marcel/Documents/pendulum-squids/node_modules/@subsquid/typeorm-store/lib/database.js:151:24) { query: 'INSERT INTO "token_transfer"("id", "block_number", "timestamp", "extrinsic_hash", "from", "to", "currency_id", "amount", "remark") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, DEFAULT) ON CONFLICT ( "id" ) DO UPDATE SET "id" = EXCLUDED."id", "block_number" = EXCLUDED."block_number", "timestamp" = EXCLUDED."timestamp", "extrinsic_hash" = EXCLUDED."extrinsic_hash", "from" = EXCLUDED."from", "to" = EXCLUDED."to", "currency_id" = EXCLUDED."currency_id", "amount" = EXCLUDED."amount"', parameters: [ '0001522352-781cd-000031', 1522352, 2024-05-08T11:15:48.155Z, '0x279944f9ff33020065859b585b89b63c2bff00c6641e1e67d314d4266e3c3a8f', '6kjpZPe7tkAKD7e8UyLeLMz1vUEDgkwxXuyCrtiCWXUzhe7u', '6ijJtaZuwpZCiaVo6pSHRJbd8qejgywYsejnjfo2AVanN14E', 'XCM(0)', '904545686' ], driverError: error: current transaction is aborted, commands ignored until end of transaction block at Parser.parseErrorMessage (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:287:98) at Parser.handlePacket (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/parser.js:39:38) at Socket.<anonymous> (/Users/marcel/Documents/pendulum-squids/node_modules/pg-protocol/dist/index.js:11:42) at Socket.emit (node:events:512:28) at addChunk (node:internal/streams/readable:324:12) at readableAddChunk (node:internal/streams/readable:297:9) at Readable.push (node:internal/streams/readable:234:10) at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { length: 145, severity: 'ERROR', code: '25P02', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'postgres.c', line: '1470', routine: 'exec_parse_message' }, length: 145, severity: 'ERROR', code: '25P02', detail: undefined, hint: undefined, position: undefined, internalPosition: undefined, internalQuery: undefined, where: undefined, schema: undefined, table: undefined, column: undefined, dataType: undefined, constraint: undefined, file: 'postgres.c', line: '1470', routine: 'exec_parse_message' } Error processing event 'Contracts.ContractEmitted'. Skipping due to error: QueryFailedError: current transaction is aborted, commands ignored until end of transaction block at PostgresQueryRunner.query (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async SelectQueryBuilder.loadRawResults (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2183:25) at async SelectQueryBuilder.getRawMany (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/SelectQueryBuilder.js:646:29) at async SelectQueryBuilder.executeEntitiesAndRawResults (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/SelectQueryBuilder.js:1973:26) at async SelectQueryBuilder.getRawAndEntities (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/SelectQueryBuilder.js:684:29) at async SelectQueryBuilder.getOne (/Users/marcel/Documents/pendulum-squids/node_modules/typeorm/query-builder/SelectQueryBuilder.js:711:25) at async getBackstopPool (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/creation.js:34:12) at async Promise.all (index 0) at async handleContractEvent (/Users/marcel/Documents/pendulum-squids/lib/mappings/nabla/handleEvent.js:58:61) {
This fixes the errors in the console by setting the reference to swapFee
to null
before deleting a swap pool.
Also, I converted hex addresses to ss58 👍🏼
Closes #58.
This should be merged to
main
only after #52 is merged.Tested some of these changes locally by running the nabla indexer tests from this
wasm-deploy
branch, therefore generating some events data. This is not enough, so more events must be generated in order to test all queries.