Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: negative subgraph balances #544

Merged
merged 20 commits into from
Mar 8, 2024
Merged

Conversation

jordaniza
Copy link

@jordaniza jordaniza commented Feb 26, 2024

Description

Task ID: OS-1075

The latest version of the subgraph on polygon can be found here

Type of change

Addresses a bug causing token voting plugins created with pre-existing governance tokens to record inaccurate initial state. Full details of the issue are here, but the code changes in this PR:

  1. Add functionality in getOrCreateMember to conditionally instantiate new TokenVotingMembers with the existing Voting Power, Delegation and ERC20 Balance of the governance token. The conditional incurs the performance hits from eth_call during instantiation, but after the entity is created, we use simple diffs to keep the subgraph performant.
  2. If the user is instantiated for the first time, do not add/subtract the balance as this causes a double counting issue.
  3. If the user belongs to an existing entity, ensure that the usual behaviour occurs (current balance +/- transfer value)
  4. Address a related issue in several places, where the composite key memberId (${pluginAddress}_${userAddress}) would often have the userAddress and pluginAddress swapped. This is not an exhaustive fix and we should check this across the codebase.
  5. Add matchstick tests as needed.
  6. A context variable has been added to keep a record of the token address of the governance token. This allows us to make eth_calls against the governance token contract from within the handlers.

I also added a declaration file to provide some missing typings for assemblyScript.

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have selected the correct base branch.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings.
  • Any dependent changes have been merged and published in downstream modules.
  • I ran all tests with success and extended them if necessary.
  • I have updated the CHANGELOG.md file in the root folder.
  • I have updated the DEPLOYMENT_CHECKLIST file in the root folder.
  • I have updated the UPDATE_CHECKLIST file in the root folder.

@jordaniza jordaniza marked this pull request as draft February 26, 2024 17:07
@jordaniza jordaniza marked this pull request as ready for review February 27, 2024 12:45
@jordaniza jordaniza marked this pull request as draft March 4, 2024 13:08
@jordaniza jordaniza marked this pull request as ready for review March 6, 2024 09:44
@github-actions github-actions bot removed the contracts label Mar 7, 2024
Copy link
Contributor

@josemarinas josemarinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thank you 🙏

@jordaniza jordaniza merged commit 19f4c42 into develop Mar 8, 2024
16 checks passed
@novaknole novaknole deleted the fix/negative-subgraph-balances branch November 5, 2024 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants