Skip to content

Fix/4823 validator profile#4849

Merged
mnaamani merged 52 commits intoJoystream:masterfrom
chrlschwb:fix/4823-validator
Sep 13, 2023
Merged

Fix/4823 validator profile#4849
mnaamani merged 52 commits intoJoystream:masterfrom
chrlschwb:fix/4823-validator

Conversation

@chrlschwb
Copy link
Copy Markdown
Contributor

fix #4823

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

The mapping looks good. Please reset the changes to the .yarnrc.yml and query-node/schemas/content.graphql

Also please test the mapping in tests/network-tests/src/flows/membership/updatingProfile.ts

"Social media handles, email address..."
externalResources: [MembershipExternalResource] @derivedFrom(field: "memberMetadata")

isVerified: Boolean!
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since this is not in a separate entity anymore. Please rename it to something more explicit like isVerifiedValidator

Comment on lines +331 to +332
if (typeof metadata?.validatorAccount === 'string') {
member.metadata.validatorAccount = (metadata.validatorAccount || null) as string
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This could be:

Suggested change
if (typeof metadata?.validatorAccount === 'string') {
member.metadata.validatorAccount = (metadata.validatorAccount || null) as string
if (typeof metadata?.validatorAccount === 'string' && metadata.validatorAccount !== member.metadata.validatorAccount) {
member.metadata.validatorAccount = metadata.validatorAccount || undefined

To prevent resetting the verification by mistake when the same account is passed and to allow removing the validator account by passing an empty string.

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.

removing null creates error during membership update test where validatorAccount should be set to null

Copy link
Copy Markdown
Collaborator

@thesan thesan Sep 8, 2023

Choose a reason for hiding this comment

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

Nice catch ! I'm not sure of this but maybe null actually unset the value on hydra while undefined is ignored (I think I read an issue about something like that a while ago).

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

The mappings and schema are great now but as I mentioned in the last review please add a test to the membership updating profile flow.

To run the tests locally you can follow the query node README:

  1. In .env uncomment JOYSTREAM_NODE_TAG and set it to the latest testing image, currently it's: 44832c0fe83c518779d52b5b3a2dcce94ae2d805 (do not commit this change.
  2. Run the ./query-node/build.sh script to build the schema and mappings locally.
  3. Try running DEBUG=true ./query-node/run-tests.sh memberships. Hopefully it works otherwise you will have to run the full scenario all the time with DEBUG=true ./query-node/run-tests.sh (which is more time consuming).
  4. After running the tests once in (1) you might to modify them and re-run the a lot faster with REUSE_KEYS=true yarn workspace network-tests run-test-scenario memberships

If you change the mappings or the schema, you will have to redo (2) and (3).

You can check this commit for more details and ask me if you get stuck.

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

You can reset the yarn.lock by running git checkout master -- yarn.lock and committing the changes.


repeated ExternalResource externalResources = 5;

optional bool isVerifiedValidator = 6;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I just realized there shouldn't be any isVerifiedValidator here. The MembershipMetadata can only define a validatorAccount but not whether or not it's verified.

about?: string | null
avatarUri?: string | null
externalResources?: MembershipMetadata.IExternalResource[] | null
isVerifiedValidator?: boolean
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same here

Suggested change
isVerifiedValidator?: boolean

Comment on lines +71 to +73
isVerifiedValidator: isSet(this.newValues.isVerifiedValidator)
? this.newValues.isVerifiedValidator
: this.oldValues.isVerifiedValidator,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So I don't think this is needed

Suggested change
isVerifiedValidator: isSet(this.newValues.isVerifiedValidator)
? this.newValues.isVerifiedValidator
: this.oldValues.isVerifiedValidator,

Comment on lines +29 to +30
isVerifiedValidator: false,
validatorAccount: 'validator address',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So it actually test something:

Suggested change
isVerifiedValidator: false,
validatorAccount: 'validator address',
validatorAccount: 'validator address 2',

Comment on lines +44 to +45
isVerifiedValidator: false,
validatorAccount: 'validator address',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Then you could try not to pass it to check it remains:

Suggested change
isVerifiedValidator: false,
validatorAccount: 'validator address',

Comment on lines +63 to +64
isVerifiedValidator: false,
validatorAccount: 'validator address',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Finally based on the mappings it should be removable:

Suggested change
isVerifiedValidator: false,
validatorAccount: 'validator address',
validatorAccount: '',

{
handle: 'New handle 1',
name: 'New name',
isVerifiedValidator: false,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
isVerifiedValidator: false,

? this.newValues.isVerifiedValidator
: this.oldValues.isVerifiedValidator,
validatorAccount: isSet(this.newValues.validatorAccount)
? this.newValues.validatorAccount
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We expect the validatorAccount to be null (i.e removed) when an empty string was passed:

Suggested change
? this.newValues.validatorAccount
? this.newValues.validatorAccount || null

Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

Good job just a few last minor changes

constructor(api: ApiPromise, treasuryAccountUri: string, miniSecret: string) {
this.api = api
this.keyring = new Keyring({ type: 'sr25519', ss58Format: JOYSTREAM_ADDRESS_PREFIX })
this.keyring = new Keyring({
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please use git to remove the changes on this file to reduce potential conflicts later

chrlschwb and others added 3 commits September 8, 2023 06:04
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
Co-authored-by: Theophile Sandoz <theophile.sandoz@gmail.com>
Copy link
Copy Markdown
Collaborator

@thesan thesan left a comment

Choose a reason for hiding this comment

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

💯

Copy link
Copy Markdown
Contributor

@zeeshanakram3 zeeshanakram3 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 overall. Please revert the changes in query-node/chain-metadata/*.json files. These are auto-generated files that should be edited.

Copy link
Copy Markdown
Contributor

@zeeshanakram3 zeeshanakram3 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

QN: Validator profile

4 participants