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

Bank::check_reserved_keys #3100

Merged
merged 4 commits into from
Oct 17, 2024
Merged

Conversation

apfitzge
Copy link

@apfitzge apfitzge commented Oct 7, 2024

Problem

  • We need a generic way to re-verify some transaction state that depends on features/state

Summary of Changes

  • Add Bank::check_reserved_keys

Fixes #

@apfitzge apfitzge self-assigned this Oct 7, 2024
@apfitzge apfitzge force-pushed the reverify_transaction branch from f8e45c9 to 9f17ee5 Compare October 7, 2024 18:22
@apfitzge
Copy link
Author

apfitzge commented Oct 8, 2024

@ryoqun @jstarry how do you feel about this approach? want to get opinion before I start writing tests for it

@jstarry
Copy link

jstarry commented Oct 8, 2024

This looks like an improvement because we actually don't need to do a full signature verification at epoch boundaries. Looks like regardless of epoch boundary we still need to do the precompile verification and reload the ALTs. So the only thing we need to do at the epoch boundary is check if new reserved keys have been added this epoch?

@apfitzge apfitzge force-pushed the reverify_transaction branch from 9f17ee5 to bc65939 Compare October 15, 2024 18:44
Comment on lines 5854 to 5861
// Precompiles may be verified at this time if feature is not activated.
// Precompile verification can be dependent on features of the bank.
let move_precompile_verification_to_svm = self
.feature_set
.is_active(&feature_set::move_precompile_verification_to_svm::id());
if !move_precompile_verification_to_svm {
verify_precompiles(tx, &self.feature_set)?;
}
Copy link
Author

@apfitzge apfitzge Oct 15, 2024

Choose a reason for hiding this comment

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

As I was going through to write tests, I've become a bit unsure this is necessary.

Is there a way to deactivate a feature? iirc (at least on mnb) they are only activated.

If the transaction initially passed verification (will have to reach this point), then there's no way this could fail if we've only activated features since. If we can deactivate them, then this is necessary because a precompile's activation could have been removed

@jstarry wdyt?

Copy link

Choose a reason for hiding this comment

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

Well in theory we could add a new precompile but yeah very unlikely to add one before we move precompile verification to the SVM. How about we skip precompile reverification and just add a comment to the PRECOMPILES static saying that if a new precompile is added, we will need to be mindful of reverifying them at epoch boundaries?

Copy link
Author

Choose a reason for hiding this comment

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

Oh actually we should leave this. We verify the precompiles in the worker threads for parallelism. So this is not necessarily re-verifying, just verifying for first time.

@apfitzge apfitzge marked this pull request as ready for review October 16, 2024 14:02
@apfitzge apfitzge requested a review from jstarry October 16, 2024 14:06
return Err(TransactionError::ResanitizationNeeded);
}
// Epoch has rolled over. Need to re-verify the transaction.
bank.reverify_transaction(tx)?;
Copy link

Choose a reason for hiding this comment

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

I think it would be easier to follow this map function if this epoch rollover if branch was only responsible for checking the reserved key set. Then, rather than having an else branch, we always check if the ALT expired and always do precompile verification (until it's moved to SVM)

Copy link
Author

Choose a reason for hiding this comment

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

god damn how did i not see that. thanks!

Copy link
Author

Choose a reason for hiding this comment

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

@apfitzge apfitzge changed the title Bank::reverify_transaction Bank::check_reserved_keys Oct 16, 2024
jstarry
jstarry previously approved these changes Oct 16, 2024
Copy link

@jstarry jstarry left a comment

Choose a reason for hiding this comment

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

Much easier to follow now, just need to fix CI and should be good to go

@apfitzge apfitzge force-pushed the reverify_transaction branch from 032415e to 89575d3 Compare October 16, 2024 19:39
@apfitzge
Copy link
Author

rebasing and hoping CI downstream issues resolve themselves 😬

@apfitzge apfitzge merged commit 657052f into anza-xyz:master Oct 17, 2024
40 checks passed
@apfitzge apfitzge deleted the reverify_transaction branch October 17, 2024 15:33
ray-kast pushed a commit to abklabs/agave that referenced this pull request Nov 27, 2024
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.

2 participants