Repository navigation
fix(scenarios): apply overrides only when the surfnet produces their slot #38
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
Changes from all commits
8434ebc
ae0483e
0d0566a
1aa6440
ea1d829
bd5dc8b
ea41ad9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2855,13 +2855,26 @@ impl SurfnetSvmLocker { | |
| self.with_svm_reader(Self::offline_account_owners) | ||
| } | ||
|
|
||
| /// Registers a scenario for execution | ||
| /// Schedules a scenario's overrides from `slot`, or from the next slot when omitted. | ||
| /// A base slot that is already produced is rejected: nothing would ever apply it. | ||
| pub fn register_scenario( | ||
| &self, | ||
| scenario: surfpool_types::Scenario, | ||
| slot: Option<Slot>, | ||
| ) -> SurfpoolResult<()> { | ||
| self.with_svm_writer(move |svm_writer| svm_writer.register_scenario(scenario, slot)) | ||
| self.with_svm_writer(move |svm_writer| { | ||
| let current_slot = svm_writer.get_latest_absolute_slot(); | ||
| let next_slot = current_slot | ||
| .checked_add(1) | ||
| .ok_or_else(|| SurfpoolError::internal("the slot counter overflowed"))?; | ||
| let base_slot = slot.unwrap_or(next_slot); | ||
| if base_slot <= current_slot { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rejects slots that are already produced, but nothing guards against a slot the clock will skip. Time travel runs |
||
| return Err(SurfpoolError::invalid_params(format!( | ||
| "base slot {base_slot} is already produced; the next slot is {next_slot}" | ||
| ))); | ||
| } | ||
| svm_writer.register_scenario(scenario, Some(base_slot)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The base-slot check validates input up front, but
Now that this function owns RPC validation, it's cheap to check every There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The locker always passes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| }) | ||
| } | ||
|
|
||
| /// Materializes overrides for a specific slot (not necessarily the current slot) | ||
|
|
||
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.
The response only reports
get_latest_absolute_slot(), so callers can't tell which base slot was chosen, and the docs tell them to wait for that slot. Return the base slot fromregister_scenario, e.g.SurfpoolResult<Slot>, and include it in the response (as the value or in the context). That spares SDK and Studio callers from assumingcontext.slot + 1, which a block produced between registration and response would make wrong.