-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Move address_lookup_table program id declaration to solana-program #30617
Move address_lookup_table program id declaration to solana-program #30617
Conversation
4d4894a
to
9202ed8
Compare
It's being moved to solana-program, not solana-sdk, though |
thanks for pointing it out, reworded. |
The idea of #23700 is to have less stuff in solana-sdk / solana-program. Having everything in those crates has caused unclear issues like #30515, where people got build errors for So in general, we should come up with a way to isolate programs in their crates rather putting more stuff in the sdk / program, same as spl program crates. What's the motivation for moving this? |
@joncinque and I chatted offline, I updated PR description and added a test that demonstrate the potential use case. |
// encapsulated within program-runtime, accessible to both invoke_context | ||
// (to make builtins to consume CUs) and by runtime::cost_model. | ||
// | ||
lazy_static::lazy_static! { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This static HashMap currently exists in runtime
, not directly accessible by program-runtime::invoke_context
. IMO it makes sense to define native's default cost in program-runtime
, where compute_budget
declares costs for various actions. Other option is to pass the default costs HashMap from runtime
via builtin programs call chain to invoke_context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Native programs are defined / built on top of program-runtime
, so it makes more sense to me to define their costs somewhere above program-runtime
.
Currently, the way it goes:
- the compute budget defines costs for syscalls that are implemented in the program-runtime
- the runtime defines costs for its native programs
- the runtime passes native programs down to the invoke context
So you could even have a cost field in invoke_context::BuiltinProgram
, and deduct straight from there, and that way it'll be impossible to define a new builtin program and forget to associate a cost. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it makes more sense to me to define their costs somewhere above program-runtime.
While I think IDs can be declared elsewhere, but totally agree costs should be defined above program-runtime,
I like the idea a lot for builtin program to carry a mandatory cost field. That removes the extra HashMap<program_id, cost> which is hard to maintain separately. Also have builtin developer to identify its default cost is way better than what's been done so far. (can also promote dev to implement more complex builtins to properly consume units).
I made POC PR #30639 , is this somewhat close to what's in your mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Address-lookup-table-program is the new way to go, what's our plan for existing builtins that somewhat resides in solana-program/SDk? Will they be refactored into self-contain crate just like ALT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no plan in place just yet to move existing declarations back up, but we could:
- deprecate native programs in
solana-program
and add them with crate features, which are enabled by default, ie. "stake" feature includes all of the stake program bindings - undeprecate their re-exports from their crates, ie.
solana-stake-program
becomes the place to import from - add the proper compile guards, just like the ALT program
- whenever we do v2, completely move the structs / instructions / ids into their crates
It's kind of a dumpy situation (that I put us in 😓 ). it's always tougher to move something up than down, especially for people that depend on it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, good to know. Thanks for the explanation!
(solana_program::bpf_loader_upgradeable::id(), 2370), | ||
(solana_program::bpf_loader_deprecated::id(), 1140), | ||
(solana_program::bpf_loader::id(), 570), | ||
// inconsistent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still have two inconsistencies to address
Co-authored-by: mvines <mvines@gmail.com>
Co-authored-by: mvines <mvines@gmail.com>
2c9662e
to
0ccb9f9
Compare
0ccb9f9
to
7e91c3d
Compare
close it in favor of #30639 (discussion #30617 (comment)) |
Problem
address_lookup_table_program
ID is declared in its own crate, one has to pull in the program crate in order to use itsid()
. This would result circular dependencies if trying to use itsid()
from lower lever, eg. fromprogram-runtime
.One use case is #30620 to make builtins to consume CUs at
invoke_context::process_executable_chain()
. I addedtest_define_default_cost_for_builtins
toprogram-runtime::invoke_context
to demonstrate possible use case.Since program IDs are statically/globally declared, perhaps make sense not to encapsulate it into program crate.
Summary of Changes
solana-program
alone with other native programs.solana-program
for ID.Fixes #