Skip to content
This repository was archived by the owner on Jan 24, 2025. It is now read-only.

Native onchain development - Updated program state management lesson #413

Conversation

0xCipherCoder
Copy link
Contributor

@0xCipherCoder 0xCipherCoder commented Sep 3, 2024

Problem

Summary of Changes

  • Updated content as per given guidelines.
  • Updated styling and grammar fixes
  • Updated code snippets with latest Rust and solana program
  • Updated program code and updated link

Fixes #
Updated program code - https://beta.solpg.io/66d67458cffcf4b13384d331

Copy link
Contributor

@mikemaccana mikemaccana left a comment

Choose a reason for hiding this comment

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

A few changes are required, see the comments above, but this looks good. 👍 Note multiple people are competing for this lessons s competition is hot!

Comment on lines 19 to 20
- A Program Derived Address (PDA) is derived from a program ID and optional
seeds, and it is used as the address for a storage account.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is better than the old version but we can improve it by starting with the purpose (storing data).

Suggested change
- A Program Derived Address (PDA) is derived from a program ID and optional
seeds, and it is used as the address for a storage account.
- State is stored in a Program Derived Address (PDA) accounts. A PDA is derived from a program ID and optional seeds, and the data inside is determined by the programmer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Improved this as per suggestions.

Comment on lines 34 to 38
This model is flexible but can be challenging if you're unfamiliar with it. In
this lesson, we'll start simple and gradually introduce more complex programs.
You'll learn the basics of state management in a Solana program, including
representing the state as a Rust type, creating accounts using PDAs, and
serializing account data.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
This model is flexible but can be challenging if you're unfamiliar with it. In
this lesson, we'll start simple and gradually introduce more complex programs.
You'll learn the basics of state management in a Solana program, including
representing the state as a Rust type, creating accounts using PDAs, and
serializing account data.
This model is simple, providing an easy-to-use key-value store to store data, and allowing programs to be upgraded without affecting their data, but can be challenging if you're familiar with older blockchains. In
this lesson, we'll start simple and gradually introduce more complex programs.
You'll learn the basics of state management in a Solana program, including
representing the state as a Rust type, creating accounts using PDAs, and
serializing account data.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again yours was better than the old one, but we can go even further. PDAs are simple, they're generally only hard for Eth people.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated for better readability and clarity. Let me know if it needs further improvement.

Comment on lines +42 to +48
All Solana accounts have a data field that holds a byte array, making accounts
as flexible as files on a computer. You can store anything in an account, as
long as it has the necessary storage space.

All Solana accounts have a `data` field that holds a byte array. This makes
accounts as flexible as files on a computer. You can store literally anything in
an account (so long as the account has the storage space for it).
Just like files in a traditional filesystem conform to specific formats like PDF
or MP3, data stored in a Solana account must follow a pattern to be retrieved
and deserialized into something usable.
Copy link
Contributor

Choose a reason for hiding this comment

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

Excellent, concise simple explanation.

[first part of this lesson](basic-program-pt-1), this is very similar to what we
did when we created an enum to represent discrete instructions.
Rust data type. This is similar to how we created an enum to represent discrete
instructions in the [first part of this lesson](basic-program-pt-1).
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this link is bad. Previous lesson should be deserialize-instruction-data. See CONTRIBUTING for how to do links (it's unusual, but there's. reason for it)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed link as per guidelines to point to the enum section.

@0xCipherCoder
Copy link
Contributor Author

A few changes are required, see the comments above, but this looks good. 👍 Note multiple people are competing for this lessons s competition is hot!

Thanks! @mikemaccana I have updated the content and resolved all the comments. Please review and let me know if there is any additional feedback.

@mikemaccana mikemaccana merged commit b3cc5bf into solana-foundation:main Sep 11, 2024
2 checks passed
@mikemaccana
Copy link
Contributor

More excellent work and another winner. 🏆

@0xCipherCoder
Copy link
Contributor Author

More excellent work and another winner. 🏆

Thanks! @mikemaccana

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants