Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 401
feat(batcher): get last max fee msg#2127
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
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6bb2431
feat: get last max fee limit message
MarcosNicolau b804457
feat: retrieve last max fee in sdk
MarcosNicolau 5bcb92e
feat: get_last_max_fee in cli
MarcosNicolau dc4f841
Update crates/batcher/src/lib.rs
MarcosNicolau 2e229b4
docs: update cli and sdk reference
JuArce af1c7c4
drop user states lock early
MarcosNicolau 59dc1e3
remove redundant comment
MarcosNicolau b8b65d7
Update crates/batcher/src/lib.rs
MarcosNicolau 356cb78
Merge branch 'staging' into feat/batcher-get-last-max-fee-msg
MarcosNicolau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -33,9 +33,9 @@ use aligned_sdk::common::constants::{ | ||
| RESPOND_TO_TASK_FEE_LIMIT_PERCENTAGE_MULTIPLIER, | ||
| }; | ||
| use aligned_sdk::common::types::{ | ||
| ClientMessage, GetNonceResponseMessage, NoncedVerificationData, ProofInvalidReason, | ||
| ProvingSystemId, SubmitProofMessage, SubmitProofResponseMessage, VerificationCommitmentBatch, | ||
| VerificationData, VerificationDataCommitment, | ||
| ClientMessage, GetLastMaxFeeResponseMessage, GetNonceResponseMessage, NoncedVerificationData, | ||
| ProofInvalidReason, ProvingSystemId, SubmitProofMessage, SubmitProofResponseMessage, | ||
| VerificationCommitmentBatch, VerificationData, VerificationDataCommitment, | ||
| }; | ||
| use aws_sdk_s3::client::Client as S3Client; | ||
| @@ -916,6 +916,11 @@ impl Batcher { | ||
| .handle_submit_proof_msg(msg, ws_conn_sink) | ||
| .await | ||
| } | ||
| ClientMessage::GetLastMaxFee(address) => { | ||
| self.clone() | ||
| .handle_get_last_max_fee(address, ws_conn_sink) | ||
| .await | ||
| } | ||
| } | ||
| } | ||
| @@ -1004,6 +1009,84 @@ impl Batcher { | ||
| Ok(()) | ||
| } | ||
| async fn handle_get_last_max_fee( | ||
| self: Arc<Self>, | ||
| mut address: Address, | ||
| ws_conn_sink: WsMessageSink, | ||
| ) -> Result<(), Error> { | ||
| // If the address is not paying, we will return the last max fee of the aligned_payment_address | ||
| if !self.has_to_pay(&address) { | ||
| info!("Handling nonpaying message"); | ||
| let Some(non_paying_config) = self.non_paying_config.as_ref() else { | ||
| warn!( | ||
| "There isn't a non-paying configuration loaded. This message will be ignored" | ||
| ); | ||
| send_message( | ||
| ws_conn_sink.clone(), | ||
| GetLastMaxFeeResponseMessage::InvalidRequest( | ||
| "There isn't a non-paying configuration loaded.".to_string(), | ||
| ), | ||
| ) | ||
| .await; | ||
| return Ok(()); | ||
| }; | ||
| let replacement_addr = non_paying_config.replacement.address(); | ||
| address = replacement_addr; | ||
| } | ||
| let user_states_guard = match timeout(MESSAGE_HANDLER_LOCK_TIMEOUT, self.user_states.read()) | ||
| .await | ||
| { | ||
| Ok(guard) => guard, | ||
| Err(_) => { | ||
| warn!("User states read lock acquisition timed out in handle_get_last_max_fee_for_address_msg"); | ||
| self.metrics.inc_message_handler_user_states_lock_timeouts(); | ||
| send_message(ws_conn_sink, GetLastMaxFeeResponseMessage::ServerBusy).await; | ||
| return Ok(()); | ||
| } | ||
| }; | ||
| let Some(usr_ref) = user_states_guard.get(&address).cloned() else { | ||
| drop(user_states_guard); | ||
| send_message( | ||
| ws_conn_sink.clone(), | ||
| GetLastMaxFeeResponseMessage::LastMaxFee(U256::MAX), | ||
| ) | ||
| .await; | ||
| return Ok(()); | ||
| }; | ||
| let Some(usr_lock) = self | ||
| .try_user_lock_with_timeout(address, usr_ref.lock()) | ||
| .await | ||
| else { | ||
| drop(user_states_guard); | ||
| send_message( | ||
| ws_conn_sink.clone(), | ||
| GetLastMaxFeeResponseMessage::ServerBusy, | ||
| ) | ||
| .await; | ||
| return Ok(()); | ||
| }; | ||
| let proofs_in_queue = usr_lock.proofs_in_batch; | ||
| let max_fee = if proofs_in_queue > 0 { | ||
| usr_lock.last_max_fee_limit | ||
| } else { | ||
| U256::MAX | ||
| }; | ||
| drop(usr_lock); | ||
| drop(user_states_guard); | ||
MarcosNicolau marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| send_message( | ||
| ws_conn_sink.clone(), | ||
| GetLastMaxFeeResponseMessage::LastMaxFee(max_fee), | ||
| ) | ||
| .await; | ||
| Ok(()) | ||
| } | ||
| /// Returns the Aligned-funded address that will be used to pay for proofs when users don't need to pay themselves. | ||
| /// This function assumes that the non-paying configuration is set. | ||
| fn aligned_payment_address(&self) -> Address { | ||
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.