-
Notifications
You must be signed in to change notification settings - Fork 266
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 Transaction Trait #1918
Conversation
@LucasSte @t-nelson @Lichtso @buffalojoec Could I get input on naming here? I have a few options in the PR description, or feel free to submit your own idea(s) Another open question is whether or not the traits should live inside of SVM or as a separate crate like I've done above. |
I'm in favor of this! I also think it should be its own crate, as you have it. My thoughts on naming: |
I like these more than the current names I have |
If we call this solana-transaction what do we call the crate we make when solana_sdk::transaction finally gets its own crate? Fully support making this a new crate whatever we call it. I suggest |
This is just my own bias, but I don't like putting "trait" or "struct" in the names, I'd lean toward |
If they were the same crate then there would be more chance of users getting confused by the Instruction and MessageAddressTableLookup structs that this crate has. Plus there'd be more bloat and it would be harder to rip out what's needed for transactions from solana-sdk, e.g. this crate requires solana_sdk::packet, which is not required by solana_sdk::transaction |
These names are good. I couldn't think of anything better (I'm terrible at naming things). |
I actually want I think whatever name we choose, this should be a separate crate from the sdk transaction. |
|
||
/// Returns the message hash. | ||
// TODO: consider moving this to Message | ||
fn message_hash(&self) -> &Hash; |
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.
for SanitizedTransaction
this just fetches a pre-computed message hash, which is why i'd put it here.
That's a current implementation detail and I feel doesn't make too much sense honestly.
Could also override the impl for SanitizedTransaction to get the cached value, while calculating it on SanitizedMessage and then move this to the MessageTrait
|
||
/// Returns true if the transaction is a simple vote transaction. | ||
// TODO: consider moving this to Message | ||
fn is_simple_vote_transaction(&self) -> bool; |
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.
same comment here as for message_hash
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.
ended up removing these 2 functions + conversion to VersionedTransaction
.
Trimmed the traits down to what is necessary for SVM, and will have some extension that can be used inside core/runtime.
I guess it wouldn't hurt to at least consider They don't look as nice as
Not sure if this makes the relationship any more clear, but you could have Or maybe it's even |
This was my original idea, but I'm a bit hesistant since there are a few things in the interface that are not strictly necessary for SVM, but are there for either the use inside of Runtime or Core. |
Put me on record as strongly opposed to calling the new crate solana-transaction for the reasons above |
ended up just going with nit on myself: any preference for SVM vs Svm in trait naming? Seems "proper" to do SVM, but also a bit unwieldy to read |
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.
Nice, looking great! I left a few comments.
svm-transaction/Cargo.toml
Outdated
solana-program = { workspace = true } | ||
solana-sdk = { 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.
You only need solana-sdk
here, since it re-exports all of solana-program
.
I'll raise a question here about a related change. There are several convenience functions that I plan to implement which use this trait, but imo don't belong on the trait itself. Some examples of functions I anticipate adding to that new module/crate: fn writable_accounts_iter(message: &impl SVMMessage) -> impl Iterator<Item = &Pubkey> + Clone;
fn readable_accounts_iter(message: &impl SVMMessage) -> impl Iterator<Item = &Pubkey> + Clone;
fn verify_precompiles(message: &impl SVMMessage) -> Result<(), TransactionError>;
fn get_durable_nonce(message: &impl SVMMessage) -> Option<&Pubkey>;
fn get_signature_details(message: &impl SVMMessage) -> TransactionSignatureDetails; My gut feeling is these belong in some dependent crate, but wonder if you all think these belong in the same crate? |
I'd agree and lean toward a separate crate - maybe something like |
38e35bc
to
869cb57
Compare
8950611
to
d131fea
Compare
@buffalojoec @LucasSte I removed a few extra things from SVMTransaction; it only has the accessors for signatures. |
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.
Nice, lgtm!
I think the other stuff can be an extended trait that is only used inside of core/runtime. Since we never use that stuff inside of SVM I think that makes more sense.
Yep, I agree. This makes more sense.
Problem
SanitizedTransaction
is extremely slow in block-productionSanitizedTransaction
.Summary of Changes
MessageTrait
,TransactionTrait
MessageTrait
is effectively to abstract currentSanitizedMessage
TransactionTrait
is an extension ofMessageTrait
that is effectively to abstractSanitizedTransaction
SanitizedMessage
andSanitizedTransaction
&T
ifT
implements traitsimpl core::borrow::Borrow<SanitizedTransaction>
MessageTrait
,TransactionTrait
Message
,SignedMessage
(@Lichtso had mentioned to me that he felt we use "transaction" incorrectly right now, and a "transaction" is a loaded message. i.e. users always send messages, transactions are what come out of those messages).solana-transaction-trait
solana-signed-message
Fixes #