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

[WIP] Enable ChainReader to read PDA account state #1003

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

amit-momin
Copy link
Contributor

Enable the ChainReader to read PDA account state

  • Added Seed config which can be configured as either directly as a Value or as a Location that is found in the provided params
  • Updated the ReadDefinition to include a list of Seed configs
  • Introduced a new pdaReadBinding type with custom logic to calculate PDAs using seeds and the bound program ID
  • Updated readBinding's GetAddress method to intake params to use for seeds when calculating the PDA

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
68.9% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

Copy link
Contributor

@silaslenihan silaslenihan left a comment

Choose a reason for hiding this comment

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

This all looks great to me! Really readable and straightforward. Not sure if you're done adding functionality for CCIP but this should unblock the interface tests

))
var reader readBinding
// Create PDA read binding if Seeds config is non-nil
// Note: Empty seeds list is a valid configuration for a PDA so a length check is intentionally skipped
Copy link
Contributor

Choose a reason for hiding this comment

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

Would an empty seeds list just be a normal account read?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think FindProgramAddress still outputs a different programID even with empty seeds since it's still applying the bump seed. I think every PDA in the on-chain code uses some sort of seed though. So guess it wouldn't hurt to also validate empty seeds for our current use case but I wanted to keep this open in case something changes in the future.

}

seedByteArray := make([][]byte, 0, len(b.seeds))
for _, seed := range b.seeds {
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for reusing some of the chainwriter seeds functionality! makes it a lot easier to understand both

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.

2 participants