-
Notifications
You must be signed in to change notification settings - Fork 306
feat: Delayed block processing for Fortuna #2307
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
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4af81d5
feat: add delayed block processing and bump minor version
devin-ai-integration[bot] fb0568c
fix: add clippy allow attribute for too many arguments
devin-ai-integration[bot] 71e1a2f
fix: remove trailing whitespace in config.sample.yaml
devin-ai-integration[bot] db9439b
refactor: move block delays to EthereumConfig and support multiple de…
devin-ai-integration[bot] c6de6ae
fix: pass only block delays param and subtract delays
devin-ai-integration[bot] 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| [package] | ||
| name = "fortuna" | ||
| version = "7.3.0" | ||
| version = "7.4.0" | ||
| edition = "2021" | ||
|
|
||
| [dependencies] | ||
|
|
||
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 |
|---|---|---|
|
|
@@ -250,7 +250,7 @@ impl KeeperMetrics { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| #[derive(Debug, Clone)] | ||
| pub struct BlockRange { | ||
| pub from: BlockNumber, | ||
| pub to: BlockNumber, | ||
|
|
@@ -346,7 +346,8 @@ pub async fn run_keeper_threads( | |
| ) | ||
| .in_current_span(), | ||
| ); | ||
| // Spawn a thread that listens for block ranges on the `rx` channel and processes the events for those blocks. | ||
|
|
||
| // Spawn a thread for block processing with configured delays | ||
| spawn( | ||
| process_new_blocks( | ||
| chain_state.clone(), | ||
|
|
@@ -356,6 +357,7 @@ pub async fn run_keeper_threads( | |
| chain_eth_config.escalation_policy.clone(), | ||
| metrics.clone(), | ||
| fulfilled_requests_cache.clone(), | ||
| chain_eth_config.clone(), | ||
| ) | ||
| .in_current_span(), | ||
| ); | ||
|
|
@@ -965,8 +967,10 @@ pub async fn watch_blocks( | |
| } | ||
| } | ||
|
|
||
| /// It waits on rx channel to receive block ranges and then calls process_block_range to process them. | ||
| /// It waits on rx channel to receive block ranges and then calls process_block_range to process them | ||
| /// for each configured block delay. | ||
| #[tracing::instrument(skip_all)] | ||
| #[allow(clippy::too_many_arguments)] | ||
| pub async fn process_new_blocks( | ||
| chain_state: BlockchainState, | ||
| mut rx: mpsc::Receiver<BlockRange>, | ||
|
|
@@ -975,12 +979,14 @@ pub async fn process_new_blocks( | |
| escalation_policy: EscalationPolicyConfig, | ||
| metrics: Arc<KeeperMetrics>, | ||
| fulfilled_requests_cache: Arc<RwLock<HashSet<u64>>>, | ||
| chain_eth_config: EthereumConfig, | ||
| ) { | ||
| tracing::info!("Waiting for new block ranges to process"); | ||
| loop { | ||
| if let Some(block_range) = rx.recv().await { | ||
| // Process blocks immediately first | ||
| process_block_range( | ||
| block_range, | ||
| block_range.clone(), | ||
| Arc::clone(&contract), | ||
| gas_limit, | ||
| escalation_policy.clone(), | ||
|
|
@@ -990,6 +996,25 @@ pub async fn process_new_blocks( | |
| ) | ||
| .in_current_span() | ||
| .await; | ||
|
|
||
| // Then process with each configured delay | ||
| for delay in &chain_eth_config.block_delays { | ||
| let adjusted_range = BlockRange { | ||
| from: block_range.from + delay, | ||
| to: block_range.to + delay, | ||
|
||
| }; | ||
| process_block_range( | ||
| adjusted_range, | ||
| Arc::clone(&contract), | ||
| gas_limit, | ||
| escalation_policy.clone(), | ||
| chain_state.clone(), | ||
| metrics.clone(), | ||
| fulfilled_requests_cache.clone(), | ||
| ) | ||
| .in_current_span() | ||
| .await; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
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.
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.
please pass only the block delay parameter here (not the whole config)