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

Extract account-info crate #2429

Merged
merged 8 commits into from
Sep 25, 2024
Merged

Conversation

kevinheavey
Copy link

Problem

account_info.rs needs to be made available outside solana-program

This branches off #2413 so that needs to be merged first

Summary of Changes

  • Move to its own crate and re-export in solana-program for backwards compatibility
  • Make bincode optional in the new crate

@kevinheavey kevinheavey force-pushed the extract-account-info branch 2 times, most recently from d84ff8a to a13d538 Compare August 3, 2024 14:15
Copy link

mergify bot commented Aug 9, 2024

The Firedancer team maintains a line-for-line reimplementation of the
native programs, and until native programs are moved to BPF, those
implementations must exactly match their Agave counterparts.
If this PR represents a change to a native program implementation (not
tests), please include a reviewer from the Firedancer team. And please
keep refactors to a minimum.

@kevinheavey kevinheavey force-pushed the extract-account-info branch 2 times, most recently from cba6424 to 82af211 Compare September 17, 2024 00:44
@kevinheavey kevinheavey marked this pull request as ready for review September 17, 2024 01:15
Copy link

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

Just one comment, the rest looks great!

sdk/account-info/src/lib.rs Outdated Show resolved Hide resolved
sdk/program/src/entrypoint.rs Outdated Show resolved Hide resolved
@joncinque
Copy link

@yihau since this is very close, can you accept ownership of solana-account-info once it gets passed?

Copy link

@joncinque joncinque 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 to me! Will approve once the crate check passes

@kevinheavey kevinheavey added the automerge automerge Merge this Pull Request automatically once CI passes label Sep 25, 2024
Copy link

mergify bot commented Sep 25, 2024

automerge label removed due to a CI failure

@mergify mergify bot removed the automerge automerge Merge this Pull Request automatically once CI passes label Sep 25, 2024
@kevinheavey kevinheavey added the automerge automerge Merge this Pull Request automatically once CI passes label Sep 25, 2024
@mergify mergify bot merged commit 6f5be6c into anza-xyz:master Sep 25, 2024
53 checks passed
@@ -28,7 +29,7 @@ pub struct AccountInfo<'a> {
/// Program that owns this account
pub owner: &'a Pubkey,
/// The epoch at which this account will next owe rent
pub rent_epoch: Epoch,
pub rent_epoch: u64,

Choose a reason for hiding this comment

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

Why was the Epoch type replaced with u64? Since we're using Pubkey, can we keep using Epoch too, please?

Choose a reason for hiding this comment

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

Pubkey is a struct, and not a type, so it would be a breaking change to use anything else.

I might be missing something, but what's the reasoning to prefer the Epoch type alias? The idea was to avoid an extra dependency.

Choose a reason for hiding this comment

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

Pubkey is a struct, and not a type, so it would be a breaking change to use anything else.

A struct is a type ;)

I'd prefer if Epoch were a proper type too, and not just an alias. (But that's orthogonal to this discussion.)


The idea was to avoid an extra dependency.

Ah, that part makes sense. How "expensive" is it to have this extra dependency?


what's the reasoning to prefer the Epoch type alias?

Strong typing is beneficial for preventing errors/making refactors easier/etc. Since Epoch is a type alias, we lose some of that, but we still retain search and the self-documenting aspects of Epoch.

Choose a reason for hiding this comment

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

Ah, that part makes sense. How "expensive" is it to have this extra dependency?

Maybe @kevinheavey has some numbers on that, or I can whip them up

Since Epoch is a type alias, we lose some of that, but we still retain search and the self-documenting aspects of Epoch.

Gotcha, I can see from the documenting aspect that it could be useful. My thinking was that:

  • I've never seen the rent epoch used by a program
  • it introduces another dependency
  • since it's just a type alias, it doesn't really matter

For those reasons, I lean towards keeping it as is, but if you feel strongly about it, we can change it.

Choose a reason for hiding this comment

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

These points make sense to me, especially since this type is meant to be program-facing. The internal-facing structs for accounts can/do keep using Epoch, so I don't think any changes are necessary. Thanks for taking the time to explain this to me!

Choose a reason for hiding this comment

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

Sounds good! And thanks for clarifying the difference between type and type alias 😅

Copy link
Author

Choose a reason for hiding this comment

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

yeah on my machine adding the solana-clock dependency increases solana-account-info build time by 40%. It's made quite expensive by the proc macro deps in solana-clock

ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
* extract account-info crate

* make bincode optional in account-info crate

* update lock file

* update doc examples

* remove solana-program from doc examples

* remove solana-program from dev deps

* fmt

* move MAX_PERMITTED_DATA_INCREASE to account-info crate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge automerge Merge this Pull Request automatically once CI passes need:merge-assist
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants