-
Notifications
You must be signed in to change notification settings - Fork 305
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
generic get nonce and ix signers #2826
Conversation
@@ -62,6 +62,7 @@ solana-loader-v4-program = { workspace = true } | |||
solana-measure = { workspace = true } | |||
solana-metrics = { workspace = true } | |||
solana-perf = { workspace = true } | |||
solana-program = { workspace = true } |
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.
limited_deserialize
from sdk
is a trick, the one from here is what we need
} | ||
|
||
#[test] | ||
fn test_get_ix_signers() { |
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 test was copied from sdk
and just modified to test the new generic fn
@@ -345,4 +408,273 @@ mod tests { | |||
.check_and_load_message_nonce_account(&message, &bank.next_durable_nonce()) | |||
.is_none()); | |||
} | |||
|
|||
#[test] | |||
fn test_get_durable_nonce() { |
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.
afaict, there are no tests for the equivalent function in sdk
. I did my best to cover the branches in logic.
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.
looks good overall. Will look into tests if you decided to keep these functions in bank, or move them out.
@@ -184,6 +188,54 @@ impl Bank { | |||
} | |||
} | |||
|
|||
/// If the message uses a durable nonce, return the pubkey of the nonce account | |||
fn get_durable_nonce(message: &impl SVMMessage) -> Option<&Pubkey> { |
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.
Would it be possible to make this, and get_is_signer()
, functions extension of SVMMessage
, or at least make them live outside of Bank
- they don't need `bank anyway?
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.
Moved functions and tests to a new mod inside runtime
: svm_message_ext
.
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.
lgtm - just a nit and CI
runtime/src/lib.rs
Outdated
@@ -34,6 +34,7 @@ pub mod stake_weighted_timestamp; | |||
pub mod stakes; | |||
pub mod static_ids; | |||
pub mod status_cache; | |||
pub mod svm_message_ext; |
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.
Can we keep these extensions in the svm-transaction crate? Even though these methods are used by the runtime, they're still useful in other contexts. Off chain clients may want to check if a transaction uses a durable nonce for example.
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.
It'd add a dependency on bincode in svm-transaction
trait, which is undesirable.
When I talked with @buffalojoec about this we discussed creating a separate crate for derived behavior.
Not sure if we'd like to do that now, or wait until there's a larger set of derived behaviors.
Didn't feel right to create a new crate for 2 functions, but lmk if you feel that'd be more appropriate.
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.
I'm definitely in favor of leaving it in runtime until it's needed off-chain, or creating a new crate. I also agree svm-transaction
should be lightweight and basically only used to roll a custom transaction type beyond the ones provided by SDK, for interacting with the SVM API.
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.
another option is to rework the implementation to avoid bincode - would be relatively straight-forward since all we use it for is to read a 4-byte discriminant.
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.
@jstarry thoughts on which approach you think is best here?
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.
Just adding one more point to supplement my argument for the runtime/new crate. Lmk if it's off-base.
Even though nonce management is split between runtime and SVM right now, the concept of a durable nonce is actually more pertinent to the runtime, when checking transaction age. There's an argument to be made for actually making the act of advancing the nonce during transaction execution a plugin that extends SVM, since not everyone will use nonces in other execution environments.
Anyway that's my perspective on it. I think we should keep the SVM crate composable and as light as possible, opening up custom behavior through plugins implemented elsewhere rather than bloat.
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.
I agree with @buffalojoec that this is a runtime concept and doesn't make sense for it to live in the svm transaction crate. I think it's going to all make much more sense when we have a "runtime transaction" abstraction
@@ -193,7 +193,7 @@ mod tests { | |||
setup_nonce_with_bank, | |||
}, | |||
solana_sdk::{ | |||
feature_set::FeatureSet, hash::Hash, message::Message, signature::Keypair, | |||
self, feature_set::FeatureSet, hash::Hash, message::Message, signature::Keypair, |
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.
Do you want this self
in here?
runtime/src/lib.rs
Outdated
@@ -34,6 +34,7 @@ pub mod stake_weighted_timestamp; | |||
pub mod stakes; | |||
pub mod static_ids; | |||
pub mod status_cache; | |||
pub mod svm_message_ext; |
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.
nit: I don't feel strongly about this, but I suggest a different module name like nonce_extraction_utils
(or better), to avoid this one day becoming a catch-all for SVM message extensions. Or maybe that's your intention..? 😅
runtime/src/lib.rs
Outdated
@@ -34,6 +34,7 @@ pub mod stake_weighted_timestamp; | |||
pub mod stakes; | |||
pub mod static_ids; | |||
pub mod status_cache; | |||
pub mod svm_message_ext; |
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.
Just adding one more point to supplement my argument for the runtime/new crate. Lmk if it's off-base.
Even though nonce management is split between runtime and SVM right now, the concept of a durable nonce is actually more pertinent to the runtime, when checking transaction age. There's an argument to be made for actually making the act of advancing the nonce during transaction execution a plugin that extends SVM, since not everyone will use nonces in other execution environments.
Anyway that's my perspective on it. I think we should keep the SVM crate composable and as light as possible, opening up custom behavior through plugins implemented elsewhere rather than bloat.
0e86751
to
05bd262
Compare
@buffalojoec think i hit all your comments now, forgot to ping friday! |
Problem
Summary of Changes
get_durable_nonce
andget_ix_signers
for checking transactionFixes #