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
Separate OperatorProfile in a separate table (to avoid the case where a operator edit his row while the indexer is also editing his row and therefore clear the field (if the indexer cache had not the new values)
Improve logic around profitability
PR Type
enhancement, bug fix
Description
Separated OperatorProfile into a new table and GraphQL type to prevent conflicts during updates.
Improved logic for calculating domain's current share price and updated related properties.
Refactored event processing functions to remove unused code and optimize cache handling.
Implemented batch saving to avoid large queries that could fail.
Renamed RewardEvent to Reward and updated related database schema and model exports.
Changes walkthrough 📝
Relevant files
Enhancement
11 files
epoch.ts
Update domain runtime and share calculation logic
indexers/staking-squid/src/events/epoch.ts
Changed string comparison from "AutoId" to "autoId".
Updated logic for calculating domain's current share price.
Added new properties for domain's current total shares and share price.
Logic Change The logic for determining _domain.runtime has been changed from checking for "AutoId" to "autoId". Ensure that this change aligns with expected data formats and that all dependent systems or data sources have been updated to accommodate this case sensitivity change.
Calculation Update The calculation for domain.currentSharePrice has been updated. It's crucial to verify the correctness of this new formula, especially how it handles cases where domain.currentTotalShares is zero to prevent division by zero errors or other logical flaws.
State Management Significant changes have been made to how state is managed and saved, particularly with the addition of multiple cache.set calls for domains, accounts, operators, and nominators. It's important to ensure that these changes do not introduce any race conditions or inconsistencies in state management, especially under high load.
Database Schema Changes New tables and indices have been created, especially for operator_profile. Review the schema changes to ensure they meet the application's requirements and that they are optimized for the queries they will support. Also, ensure that foreign keys and relationships are correctly defined.
Add error handling for division by zero in share price calculation
Ensure that the division operation does not throw an error when domain.currentTotalShares is zero by checking the condition before performing the division.
Why: This suggestion addresses a potential division by zero error, which is a critical issue that could cause runtime exceptions. The proposed change improves code robustness.
9
Possible issue
Use case-insensitive string comparison for "autoId"
Consider using a case-insensitive comparison for the string "autoId" to ensure consistent behavior regardless of the case used in the input data.
Why: The suggestion to use a case-insensitive comparison ensures consistent behavior regardless of input case, which is crucial for avoiding potential bugs related to string case sensitivity.
8
Maintainability
Refactor repeated withdrawal updates into a single function
Refactor the repeated code for setting total withdrawals and updating caches into a function to improve code maintainability and reduce duplication.
Why: Refactoring repeated code into a function enhances maintainability and reduces duplication, making the codebase easier to manage and less error-prone.
7
Improve variable naming for clarity in createRewardEvent call
Use a more descriptive variable name than event for the createRewardEvent function to avoid confusion with global objects or other event handlers in the context.
Why: The suggestion improves code readability and maintainability by using a more descriptive variable name, reducing potential confusion with other event-related variables.
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
Staking-squid v24
PR Type
enhancement, bug fix
Description
OperatorProfile
into a new table and GraphQL type to prevent conflicts during updates.RewardEvent
toReward
and updated related database schema and model exports.Changes walkthrough 📝
11 files
epoch.ts
Update domain runtime and share calculation logic
indexers/staking-squid/src/events/epoch.ts
price.
operator.ts
Update operator reward event handling
indexers/staking-squid/src/events/operator.ts
operatorRewards
instead ofoperatorRewardedEvents
.unlock.ts
Refactor unlock event processing and cache updates
indexers/staking-squid/src/events/unlock.ts
withdraw.ts
Update nominator pending action on withdrawal
indexers/staking-squid/src/events/withdraw.ts
operator.ts
Enhance nominator updates during operator deregistration
indexers/staking-squid/src/extrinsics/operator.ts
during operator deregistration.
index.ts
Update model exports and rename reward event
indexers/staking-squid/src/model/generated/index.ts
RewardEvent
toReward
.operatorProfile.model
.bundle.ts
Modify bundle author ID generation
indexers/staking-squid/src/storage/bundle.ts
operator.ts
Refactor operator creation and reward event handling
indexers/staking-squid/src/storage/operator.ts
cache.ts
Optimize cache handling and batch saving
indexers/staking-squid/src/utils/cache.ts
1724269616356-Data.js
Database schema changes for operator profile and rewards
indexers/staking-squid/db/migrations/1724269616356-Data.js
operator_profile
.reward_event
table toreward
.schema.graphql
Update GraphQL schema for operator profile and rewards
indexers/staking-squid/schema.graphql
OperatorProfile
type.RewardEvent
type toReward
.1 files
index.ts
Clean up unused event processing functions
indexers/staking-squid/src/events/index.ts
1 files
squid.yaml
Update staking-squid version to 24
indexers/staking-squid/squid.yaml