-
Notifications
You must be signed in to change notification settings - Fork 301
feat(fortuna): Multiple replica support #2812
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
Merged
tejasbadadare
merged 11 commits into
main
from
devin/1750801144-fortuna-multiple-replicas
Jun 26, 2025
Merged
Changes from 5 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a66fe6e
feat(fortuna): implement multiple replica support with sequence numbe…
devin-ai-integration[bot] 4801859
feat(fortuna): add delayed processing for backup replicas
devin-ai-integration[bot] 0c76fa6
docs(fortuna): add comprehensive multi-replica setup documentation
devin-ai-integration[bot] b3f630f
Merge branch 'devin/1750801144-fortuna-multiple-replicas' of https://…
devin-ai-integration[bot] 631e71d
update sample config
tejasbadadare ac5fb7a
refactor(fortuna): streamline keeper configuration and improve event …
tejasbadadare 02f280d
feat(fortuna): add provider arg to entropy load testing script
tejasbadadare 07d67bc
fix(fortuna): improve config and replica logic
tejasbadadare 3ebfbb9
fix(fortuna): names, config check
tejasbadadare 4755ce6
bump version
tejasbadadare 1a3a401
Merge branch 'main' of github.com:pyth-network/pyth-crosschain into d…
tejasbadadare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,66 @@ pub async fn process_event_with_backoff( | |
return Ok(()); | ||
} | ||
|
||
let is_primary_replica = | ||
tejasbadadare marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
if let Some(replica_config) = &process_param.keeper_config.replica_config { | ||
let assigned_replica = event.sequence_number % replica_config.total_replicas; | ||
if assigned_replica != replica_config.replica_id { | ||
tracing::debug!( | ||
sequence_number = event.sequence_number, | ||
tejasbadadare marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
assigned_replica = assigned_replica, | ||
our_replica_id = replica_config.replica_id, | ||
"Processing request as backup replica" | ||
); | ||
false | ||
} else { | ||
true | ||
} | ||
} else { | ||
true // No replica config, process all requests | ||
}; | ||
|
||
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. I think we can merge these 2 logs |
||
if !is_primary_replica { | ||
if let Some(replica_config) = &process_param.keeper_config.replica_config { | ||
tracing::info!( | ||
sequence_number = event.sequence_number, | ||
tejasbadadare marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
delay_seconds = replica_config.backup_delay_seconds, | ||
"Waiting before processing as backup replica" | ||
); | ||
tokio::time::sleep(tokio::time::Duration::from_secs( | ||
replica_config.backup_delay_seconds, | ||
)) | ||
.await; | ||
} | ||
|
||
match chain_state | ||
.contract | ||
.get_request(event.provider_address, event.sequence_number) | ||
.await | ||
{ | ||
Ok(Some(_)) => { | ||
tracing::info!( | ||
sequence_number = event.sequence_number, | ||
tejasbadadare marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"Request still open after delay, processing as backup replica" | ||
); | ||
} | ||
Ok(None) => { | ||
tracing::debug!( | ||
sequence_number = event.sequence_number, | ||
"Request already fulfilled by primary replica during delay, skipping" | ||
); | ||
return Ok(()); | ||
} | ||
Err(e) => { | ||
tracing::warn!( | ||
sequence_number = event.sequence_number, | ||
error = ?e, | ||
"Error checking request status after delay, skipping" | ||
); | ||
return Ok(()); | ||
tejasbadadare marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} | ||
} | ||
} | ||
|
||
let account_label = AccountLabel { | ||
chain_id: chain_state.id.clone(), | ||
address: chain_state.provider_address.to_string(), | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.