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 main #548

Closed
wants to merge 5 commits into from

Conversation

jordaniza
Copy link
Contributor

@jordaniza jordaniza commented Feb 28, 2024

Description

Task ID: OS-1075

Preview Subgraph 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. Grab the contract address from the event and use it to fetch the initial balance and delegation status.

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 changed the base branch from develop to main February 28, 2024 13:20
@jordaniza jordaniza marked this pull request as draft February 28, 2024 13:20
@jordaniza jordaniza marked this pull request as ready for review March 4, 2024 13:08
@jordaniza jordaniza marked this pull request as draft March 6, 2024 09:43
@jordaniza jordaniza closed this Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant