You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This PR aims to minimize data utilization in consensus tables (especially extrinsics and events).
When we upload data on the network, using auto-drive or anything that follows auto-dag-data models, this data gets indexed by the consensus indexer as the argument of the extrinsic (args column in consensus.extrinsics table).
This data can be indexed in a second table (args column in consensus.events table), if the extrinsics use is system.remarkWithEvent.
Therefore these changes convert the data into a CID if possible and replace the args by { "cid": "bafkr6i..." } and add the CID in a new column.
add auto-dag-data in consensus indexer and update other auto-sdk depencencies
add cid column in extrinsics and events table (as index)
add logic to try to parse the cid from the data and store it in db
PR Type
enhancement, configuration changes
Description
Added CID handling to consensus indexer for extrinsics and events, minimizing data size by replacing args with CID where applicable.
Updated database schema to include cid column and indexes in consensus.events and consensus.extrinsics tables.
Introduced utility functions for CID parsing and hex conversion.
Updated package dependencies to include auto-dag-data and updated versions of existing dependencies.
Extended GraphQL schema to support CID field in Extrinsic and Event types.
Changes walkthrough 📝
Relevant files
Enhancement
12 files
db.ts
Add CID parameter to database functions for extrinsics and events
indexers/mainnet/consensus/src/mappings/db.ts
Added cid parameter to createAndSaveExtrinsic and createAndSaveEvent functions.
Here are some key observations to aid the review process:
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review
Error Handling The error handling in parseDataToCid function might not be sufficient. Consider enhancing the error handling to manage different types of failures more gracefully.
Input Validation The hexToUint8Array function throws an error for odd-length hex strings but does not handle other potential invalid inputs. Consider adding more comprehensive input validation.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
Consensus indexer converts data to CID
This PR aims to minimize data utilization in consensus tables (especially extrinsics and events).
When we upload data on the network, using auto-drive or anything that follows auto-dag-data models, this data gets indexed by the consensus indexer as the argument of the extrinsic (
args
column inconsensus.extrinsics
table).This data can be indexed in a second table (
args
column inconsensus.events
table), if the extrinsics use issystem.remarkWithEvent
.Therefore these changes convert the data into a CID if possible and replace the args by
{ "cid": "bafkr6i..." }
and add the CID in a new column.PR Type
enhancement, configuration changes
Description
cid
column and indexes inconsensus.events
andconsensus.extrinsics
tables.auto-dag-data
and updated versions of existing dependencies.Extrinsic
andEvent
types.Changes walkthrough 📝
12 files
db.ts
Add CID parameter to database functions for extrinsics and events
indexers/mainnet/consensus/src/mappings/db.ts
cid
parameter tocreateAndSaveExtrinsic
andcreateAndSaveEvent
functions.
cid
.helper.ts
Implement CID parsing utility function
indexers/mainnet/consensus/src/mappings/helper.ts
auto-dag-data
.parseDataToCid
function to parse data into CID.mappingHandlers.ts
Integrate CID parsing into extrinsic and event handling
indexers/mainnet/consensus/src/mappings/mappingHandlers.ts
parseDataToCid
to handle extrinsics and events.types.ts
Define types for CID and modified arguments
indexers/mainnet/consensus/src/mappings/types.ts
Cid
,ModifiedArgs
, andParsedArgs
.utils.ts
Add utility function for hex to Uint8Array conversion
indexers/mainnet/consensus/src/mappings/utils.ts
hexToUint8Array
utility function.db.ts
Add CID parameter to database functions for extrinsics and events
indexers/taurus/consensus/src/mappings/db.ts
cid
parameter tocreateAndSaveExtrinsic
andcreateAndSaveEvent
functions.
cid
.helper.ts
Implement CID parsing utility function
indexers/taurus/consensus/src/mappings/helper.ts
auto-dag-data
.parseDataToCid
function to parse data into CID.mappingHandlers.ts
Integrate CID parsing into extrinsic and event handling
indexers/taurus/consensus/src/mappings/mappingHandlers.ts
parseDataToCid
to handle extrinsics and events.types.ts
Define types for CID and modified arguments
indexers/taurus/consensus/src/mappings/types.ts
Cid
,ModifiedArgs
, andParsedArgs
.utils.ts
Add utility function for hex to Uint8Array conversion
indexers/taurus/consensus/src/mappings/utils.ts
hexToUint8Array
utility function.schema.graphql
Extend GraphQL schema with CID field
indexers/mainnet/consensus/schema.graphql
cid
field toExtrinsic
andEvent
types.schema.graphql
Extend GraphQL schema with CID field
indexers/taurus/consensus/schema.graphql
cid
field toExtrinsic
andEvent
types.1 files
init-db.sql
Add CID column and indexes to database schema
indexers/db/docker-entrypoint-initdb.d/init-db.sql
cid
column toconsensus.events
andconsensus.extrinsics
tables.cid
in both tables.2 files
package.json
Update package dependencies for consensus indexer
indexers/mainnet/consensus/package.json
auto-consensus
,auto-dag-data
, andauto-utils
.package.json
Update package dependencies for consensus indexer
indexers/taurus/consensus/package.json
auto-consensus
,auto-dag-data
, andauto-utils
.