-
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
feat(fortuna): Multiple replica support #2812
Conversation
…r modulo filtering Co-Authored-By: Tejas Badadare <[email protected]>
- Add configurable time delay before backup replicas check request status - Backup replicas now wait backup_delay_seconds before attempting fulfillment - Add backup_delay_seconds field to ReplicaConfig with default of 30 seconds - Improves reliability by reducing race conditions between replicas Co-Authored-By: Tejas Badadare <[email protected]>
- Add Multiple Replica Setup section to README.md with modulo assignment explanation - Add replica_config examples to config.sample.yaml for 2, 3, and 5 replica setups - Include deployment considerations, failover behavior, and wallet separation requirements - Add validation for backup_delay_seconds > 0 to prevent race conditions Co-Authored-By: Tejas Badadare <[email protected]>
…git-manager.devin.ai/proxy/github.com/pyth-network/pyth-crosschain into devin/1750801144-fortuna-multiple-replicas
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
…processing - Updated config.sample.yaml by removing unnecessary blank lines. - Changed backup_delay_seconds in README.md from 45 to 30 for consistency. - Refactored run_keeper_threads to accept KeeperConfig directly instead of private_key. - Enhanced run function to handle keeper configuration more effectively. - Added comments in process_event_with_backoff to clarify primary and backup replica logic.
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.
If you are planning to deploy these changes, please bump the Cargo version too.
} | ||
} | ||
} | ||
// If no replica config we are running standalone, process all requests directly |
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.
I would put this comment at the top of this block. I generally expect comments to describe the next block or line but this seems to be a comment for a non-existent else block
tracing::debug!("Processing request as primary replica"); | ||
} else { | ||
tracing::debug!("Processing request as backup replica"); | ||
|
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.
I think we can merge these 2 logs
…evin/1750801144-fortuna-multiple-replicas
Summary
Implemented multiple Fortuna replica support with modulo-based request assignment and configurable backup delays.
Rationale
We want to improve Fortuna's reliability through redundancy, but naively running multiple Fortuna instances caused race conditions and gas waste. Now we distribute requests to specific replicas via
sequence_number % total_replicas
. All replicas still see all requests, so if a replica doesn't fulfill its assigned request, the others will try to fulfill it after the set delay.The replica assignment & delay is implemented in
process_event_with_backoff
, which plays well with the block delay and retry mechanisms. It kicks in after the block delay has already elapsed, so the effective latency for requests missed by their assigned replica is block delay + replica delay.How has this been tested?
Tested manually, works well on monad testnet. Stress tested it a bit with the load tester script and both instances were happy. Tested out killing one of them and the other one picks up the requests after the delay as expected.