Skip to content

Batch update deployment signalled tokens to Subgraph entity - #147

Merged
juanmardefago merged 4 commits into
mainnet-stagingfrom
current-signalled-tokens-refactor
Jul 30, 2021
Merged

juanmardefago merged 4 commits into
mainnet-stagingfrom
current-signalled-tokens-refactor

Conversation

@juanmardefago

Copy link
Copy Markdown
Contributor

Currently syncing here: https://thegraph.com/legacy-explorer/subgraph/juanmardefago/dev-subgraph?version=pending

Also fixed some inconsistent spacing on some files, and a weird conflict on a file that we stopped versioning a while ago.

@juanmardefago
juanmardefago requested a review from davekay100 July 22, 2021 16:07

@nenadjaja nenadjaja left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Had one question.
Might want to wait for @davekaj for approval? Unless this is urgent

Comment thread src/mappings/gns.ts
let oldVersionID = subgraph.currentVersion

versionID = joinID([subgraphID, subgraph.versionCount.toString()])
subgraph.currentVersion = versionID

@nenadjaja nenadjaja Jul 27, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shouldn't let oldVersionID = subgraph.currentVersion line of code be after this line? (After we set subgraph.currentVersion) ?

@juanmardefago juanmardefago Jul 28, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We actually want to maintain the previous version id (before we set the new one, even if it's null) that's why I do it before.
This is done to be able to properly update the old version helper entity and also the active amount of subgraphs that currently are linked to this deployment.

@davekay100 davekay100 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few questions from me

Comment thread src/mappings/metadataHelpers.ts Outdated
import { createOrLoadSubgraphCategory, createOrLoadSubgraphCategoryRelation, createOrLoadNetwork } from './helpers'

export function fetchGraphAccountMetadata(graphAccount: GraphAccount, ipfsHash: string): void {
let ipfsData = ipfs.cat(ipfsHash)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, i remember I did a commit where i made this file git ignored. in fact, .gitignore contains it right now.

i think we can just delete this file from the PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I'm not 100% sure why it was still being tracked, but since the old version contained conflict strings, I made sure to at least remove that.
I'm gonna go ahead and delete them on the update.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah i think gitignore does a weird thing where if the file EXISTS it doesnt catch it, and will continue to allow you to edit it. but then once you delete it, gitignore works properly.

Comment thread src/mappings/helpers.ts Outdated
newDeployment.activeSubgraphCount = newDeployment.activeSubgraphCount + 1
newDeployment.save()

subgraph.currentVersionRelationEntity = newRelationEntity.id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the reason for including this field on the subgraph? Just curious

@juanmardefago juanmardefago Jul 29, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

So we can update the old deployment activeSubgraphCount when it changes to a new deployment. (that counter basically adds a little bit of extra information so you can know how many subgraphs are actively using that deployment as their current version)

Comment thread src/mappings/gns.ts
oldDeployment = SubgraphDeployment.load(oldVersion.subgraphDeployment)
}
// create deployment - named subgraph relationship, and update the old one
updateCurrentDeploymentLinks(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this function, or one similar to it, will have to run on handleSubgraphDeprecated. it might be that we just need to lower the active count, and set active to false. wdyt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤔
maybe, yeah, although technically the subgraph still has the deployment as its' current version, so it might be weird when querying that data 🤔

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe it would be best to track that as a separate count, like having subgraphCount, activeSubgraphCount and deprecatedSubgraphCount, since an active subgraph for the deployment can stop being active because it was upgraded or because it was deprecated

@juanmardefago
juanmardefago force-pushed the current-signalled-tokens-refactor branch from 417bb04 to 8d8ef86 Compare July 29, 2021 22:44
@juanmardefago

Copy link
Copy Markdown
Contributor Author

@davekaj rebased to fix conflicts, and changed it to implement a different counter when deprecating, while reusing most of the original code.

@juanmardefago

Copy link
Copy Markdown
Contributor Author

@davekay100 davekay100 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@juanmardefago
juanmardefago merged commit 01adecc into mainnet-staging Jul 30, 2021
@juanmardefago
juanmardefago deleted the current-signalled-tokens-refactor branch August 2, 2021 13:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants