Skip to content

SIMD-0242: Static Nonce Account Only#5555

Merged
jstarry merged 3 commits intoanza-xyz:masterfrom
jstarry:feat/static-nonce
Apr 1, 2025
Merged

SIMD-0242: Static Nonce Account Only#5555
jstarry merged 3 commits intoanza-xyz:masterfrom
jstarry:feat/static-nonce

Conversation

@jstarry
Copy link
Copy Markdown

@jstarry jstarry commented Mar 27, 2025

Problem

Durable nonce transactions were unintentionally allowed to load their nonce accounts from address lookup tables rather than restricted to being a static account.

Summary of Changes

Implement SIMD-0242 by adding a feature gate to start requiring nonces to be static

Fixes #

@jstarry jstarry requested review from a team as code owners March 27, 2025 22:03
@jstarry jstarry force-pushed the feat/static-nonce branch from bfafac9 to 72a5c66 Compare March 27, 2025 23:02
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 28, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 3 lines in your changes missing coverage. Please review.

Project coverage is 83.3%. Comparing base (9db6491) to head (cf4f96a).
Report is 2 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##           master    #5555     +/-   ##
=========================================
- Coverage    83.4%    83.3%   -0.1%     
=========================================
  Files         827      827             
  Lines      373587   373692    +105     
=========================================
+ Hits       311580   311603     +23     
- Misses      62007    62089     +82     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

apfitzge
apfitzge previously approved these changes Mar 28, 2025
Copy link
Copy Markdown

@apfitzge apfitzge left a comment

Choose a reason for hiding this comment

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

Implementation looks correct to me.
The function that checks the nonce is static is run in both our initial scheduler filters as well as at runtime - @topointon-jump should be happy with this since the runtime check will mean this just works for frankendancer.

A follow-up qusetion I have with this change...should we allow our SDK type constructors to even construct such a transaction?

Comment thread svm-transaction/src/tests.rs Outdated
@@ -1,4 +1,5 @@
#![cfg(test)]
#![allow(clippy::arithmetic_side_effects)]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why did this become necessary?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

was just lazy when copying in some message creation code. I replaced the offending arithmetic with saturating and checked methods instead: cf4f96a

ix.accounts.first().and_then(|idx| {
let index = usize::from(*idx);
if !self.is_writable(index) {
if (require_static_nonce_account && index >= self.static_account_keys().len())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It looks like we really only require the number of static account keys;

I think exposing static account keys is reasonable. Can you think of any reason we'd want to limit the interface to only the number of static account keys?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It looks like we really only require the number of static account keys;

Yeah, just figured we will be using static_account_keys more in the future so I exposed the full slice rather than just the length.

Can you think of any reason we'd want to limit the interface to only the number of static account keys?

Nope, we always have the full list of static account keys available, seems fine to expose it

message: &impl SVMMessage,
) -> Option<(Pubkey, AccountSharedData, NonceData)> {
let nonce_address = message.get_durable_nonce()?;
let require_static_nonce_account = self
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should we pass this in instead of lookup in feature-set per transaction?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I did consider that. I didn't love that it would technically allow calling a bank method with a feature gate enabled which the bank didn't have enabled. Also this will only get called for transactions which don't have a recent blockhash, so not too bad I think. Would be nice to do some refactoring in this area tho, wdyt?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sg

LucasSte
LucasSte previously approved these changes Mar 28, 2025
@jstarry jstarry dismissed stale reviews from LucasSte and apfitzge via 934ad69 March 28, 2025 17:22
@jstarry
Copy link
Copy Markdown
Author

jstarry commented Mar 28, 2025

should we allow our SDK type constructors to even construct such a transaction?

Had the same thought, I'll look into making a change to sdk for this. Seems unlikely for any folks to have a nonce account in an ALT but still seems nice.

@jstarry
Copy link
Copy Markdown
Author

jstarry commented Mar 28, 2025

I'll look into making a change to sdk for this

SDK PR is here: anza-xyz/solana-sdk#100

Comment thread feature-set/src/lib.rs
Comment on lines +1262 to 1264
(require_static_nonce_account::id(), "SIMD-0242: Static Nonce Account Only"),
(raise_block_limits_to_60m::id(), "Raise block limit to 60M SIMD-0256"),
/*************** ADD NEW FEATURES HERE ***************/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

any reason to not put this at the end?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

to avoid git conflicts

message: &impl SVMMessage,
) -> Option<(Pubkey, AccountSharedData, NonceData)> {
let nonce_address = message.get_durable_nonce()?;
let require_static_nonce_account = self
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sg

@jstarry jstarry merged commit 19c78ed into anza-xyz:master Apr 1, 2025
58 checks passed
@jstarry jstarry deleted the feat/static-nonce branch April 1, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants