Skip to content

Commit 2582bcf

Browse files
committed
Merge branch 'main' into feat/aleo-sdk
2 parents db581ab + 78ff6cd commit 2582bcf

33 files changed

Lines changed: 700 additions & 299 deletions

.changeset/pink-beds-act.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"@hyperlane-xyz/cosmos-sdk": minor
3+
"@hyperlane-xyz/radix-sdk": minor
4+
"@hyperlane-xyz/utils": minor
5+
"@hyperlane-xyz/cli": minor
6+
"@hyperlane-xyz/sdk": minor
7+
---
8+
9+
add new methods for altvm interface

.registryrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
93a21a90c1fcff8bf6e449c1fc4db9290c43f62e
1+
eece6cd6a63a62f0afe7ffd9d9af73909db46643

rust/main/agents/relayer/src/msg/message_processor.rs

Lines changed: 70 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ async fn prepare_lander_task(
399399
continue;
400400
};
401401

402-
let batch_to_process = confirm_already_submitted_operations(
402+
let batch_to_process = filter_operations_for_preparation(
403403
entrypoint.clone() as Arc<dyn Entrypoint + Send + Sync>,
404404
&confirm_queue,
405405
db.clone(),
@@ -419,49 +419,93 @@ async fn prepare_lander_task(
419419
}
420420
}
421421

422-
/// This function checks the status of the payloads associated with the operations in the batch.
423-
/// If the payload is not dropped, the operation is pushed to the confirmation queue.
424-
/// If the payload is dropped, does not exist or there is issue in retrieving payload or its status, the operation will go through prepare logic.
425-
async fn confirm_already_submitted_operations(
422+
/// Disposition for how to handle an operation during submission check
423+
enum OperationDisposition {
424+
/// Operation requires manual intervention - should be prepared
425+
Manual,
426+
/// Operation has not been submitted yet - should be prepared
427+
Prepare,
428+
/// Operation has already been submitted - should go to confirmation queue
429+
Confirm,
430+
}
431+
432+
/// Filters operations from a batch to determine which should proceed to preparation.
433+
///
434+
/// Operations already submitted (and not dropped) are pushed to the confirmation queue.
435+
/// Operations that need preparation are returned for further processing.
436+
///
437+
/// # Returns
438+
/// A vector of operations that should proceed to the preparation phase.
439+
async fn filter_operations_for_preparation(
426440
entrypoint: Arc<dyn Entrypoint + Send + Sync>,
427441
confirm_queue: &OpQueue,
428442
db: Arc<dyn HyperlaneDb>,
429443
batch: Vec<QueueOperation>,
430444
) -> Vec<QueueOperation> {
431445
use ConfirmReason::AlreadySubmitted;
432-
use PendingOperationStatus::{Confirm, Retry};
446+
use PendingOperationStatus::Confirm;
447+
448+
// Phase 1: Determine disposition for each operation
449+
let mut operations_with_disposition = Vec::with_capacity(batch.len());
450+
for op in batch {
451+
let disposition =
452+
determine_operation_disposition(entrypoint.clone(), db.clone(), &op).await;
453+
operations_with_disposition.push((op, disposition));
454+
}
433455

434-
let mut ops_to_prepare = vec![];
435-
for op in batch.into_iter() {
436-
if let Retry(ReprepareReason::Manual) = op.status() {
437-
ops_to_prepare.push(op);
438-
continue;
439-
}
440-
if !has_operation_been_submitted(entrypoint.clone(), db.clone(), &op).await {
441-
ops_to_prepare.push(op);
442-
continue;
456+
// Phase 2: Process operations based on their disposition
457+
let mut ops_to_prepare = Vec::new();
458+
for (op, disposition) in operations_with_disposition {
459+
match disposition {
460+
OperationDisposition::Manual | OperationDisposition::Prepare => {
461+
ops_to_prepare.push(op);
462+
}
463+
OperationDisposition::Confirm => {
464+
let status = Some(Confirm(AlreadySubmitted));
465+
confirm_queue.push(op, status).await;
466+
}
443467
}
444-
let status = Some(Confirm(AlreadySubmitted));
445-
confirm_queue.push(op, status).await;
446468
}
469+
447470
ops_to_prepare
448471
}
449472

450-
async fn has_operation_been_submitted(
473+
async fn determine_operation_disposition(
451474
entrypoint: Arc<dyn Entrypoint + Send + Sync>,
452475
db: Arc<dyn HyperlaneDb>,
453476
op: &QueueOperation,
454-
) -> bool {
477+
) -> OperationDisposition {
478+
use PendingOperationStatus::Retry;
479+
480+
// Check if operation requires manual intervention
481+
if let Retry(ReprepareReason::Manual) = op.status() {
482+
return OperationDisposition::Manual;
483+
}
484+
485+
// Determine disposition based on payload status
486+
operation_disposition_by_payload_status(entrypoint, db, op).await
487+
}
488+
489+
/// Determines the disposition of an operation based on its payload submission status.
490+
/// Returns Confirm if the payload has been submitted and is not dropped, Prepare otherwise.
491+
/// If payload status cannot be determined, operation will be prepared.
492+
async fn operation_disposition_by_payload_status(
493+
entrypoint: Arc<dyn Entrypoint + Send + Sync>,
494+
db: Arc<dyn HyperlaneDb>,
495+
op: &QueueOperation,
496+
) -> OperationDisposition {
497+
use OperationDisposition::{Confirm, Prepare};
498+
455499
let id = op.id();
456500

457501
let payload_uuids = match db.retrieve_payload_uuids_by_message_id(&id) {
458502
Ok(uuids) => uuids,
459-
Err(_) => return false,
503+
Err(_) => return Prepare,
460504
};
461505

462506
let payload_uuids = match payload_uuids {
463-
None => return false,
464-
Some(uuids) if uuids.is_empty() => return false,
507+
None => return Prepare,
508+
Some(uuids) if uuids.is_empty() => return Prepare,
465509
Some(uuids) => uuids,
466510
};
467511

@@ -470,10 +514,10 @@ async fn has_operation_been_submitted(
470514
let status = entrypoint.payload_status(payload_uuid).await;
471515

472516
match status {
473-
Ok(PayloadStatus::Dropped(_)) => false,
474-
Ok(PayloadStatus::InTransaction(TransactionStatus::Dropped(_))) => false,
475-
Ok(_) => true,
476-
Err(_) => false,
517+
Ok(PayloadStatus::Dropped(_)) => Prepare,
518+
Ok(PayloadStatus::InTransaction(TransactionStatus::Dropped(_))) => Prepare,
519+
Ok(_) => Confirm,
520+
Err(_) => Prepare,
477521
}
478522
}
479523

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
mod tests_confirm_already_submitted_operations;
2-
mod tests_has_operation_been_submitted;
1+
mod tests_filter_operations_for_preparation;
2+
mod tests_operation_disposition_by_payload_status;

rust/main/agents/relayer/src/msg/message_processor/tests/tests_confirm_already_submitted_operations.rs renamed to rust/main/agents/relayer/src/msg/message_processor/tests/tests_filter_operations_for_preparation.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use lander::{
2525
use crate::msg::op_queue::OpQueue;
2626
use crate::server::operations::message_retry::MessageRetryRequest;
2727

28-
use super::super::confirm_already_submitted_operations;
28+
use super::super::filter_operations_for_preparation;
2929

3030
// Mock QueueOperation for testing
3131
#[derive(Debug, Serialize, Clone)]
@@ -294,14 +294,14 @@ fn create_test_queue() -> OpQueue {
294294
}
295295

296296
#[tokio::test]
297-
async fn test_confirm_already_submitted_operations_empty_batch() {
297+
async fn test_filter_operations_for_preparation_empty_batch() {
298298
let mock_db = MockHyperlaneDb::new();
299299
let mock_entrypoint = MockDispatcherEntrypoint::new();
300300
let confirm_queue = create_test_queue();
301301

302302
let batch = vec![];
303303

304-
let result = confirm_already_submitted_operations(
304+
let result = filter_operations_for_preparation(
305305
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
306306
&confirm_queue,
307307
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -321,7 +321,7 @@ async fn test_confirm_already_submitted_operations_empty_batch() {
321321
}
322322

323323
#[tokio::test]
324-
async fn test_confirm_already_submitted_operations_all_manual_retry() {
324+
async fn test_filter_operations_for_preparation_all_manual_retry() {
325325
let mut mock_db = MockHyperlaneDb::new();
326326
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
327327
let confirm_queue = create_test_queue();
@@ -345,7 +345,7 @@ async fn test_confirm_already_submitted_operations_all_manual_retry() {
345345

346346
let batch = vec![op1, op2, op3];
347347

348-
let result = confirm_already_submitted_operations(
348+
let result = filter_operations_for_preparation(
349349
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
350350
&confirm_queue,
351351
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -369,7 +369,7 @@ async fn test_confirm_already_submitted_operations_all_manual_retry() {
369369
}
370370

371371
#[tokio::test]
372-
async fn test_confirm_already_submitted_operations_all_submitted() {
372+
async fn test_filter_operations_for_preparation_all_submitted() {
373373
let mut mock_db = MockHyperlaneDb::new();
374374
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
375375
let confirm_queue = create_test_queue();
@@ -413,7 +413,7 @@ async fn test_confirm_already_submitted_operations_all_submitted() {
413413

414414
let batch = vec![op1, op2, op3];
415415

416-
let result = confirm_already_submitted_operations(
416+
let result = filter_operations_for_preparation(
417417
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
418418
&confirm_queue,
419419
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -437,7 +437,7 @@ async fn test_confirm_already_submitted_operations_all_submitted() {
437437
}
438438

439439
#[tokio::test]
440-
async fn test_confirm_already_submitted_operations_none_submitted() {
440+
async fn test_filter_operations_for_preparation_none_submitted() {
441441
let mut mock_db = MockHyperlaneDb::new();
442442
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
443443
let confirm_queue = create_test_queue();
@@ -459,7 +459,7 @@ async fn test_confirm_already_submitted_operations_none_submitted() {
459459

460460
let batch = vec![op1, op2];
461461

462-
let result = confirm_already_submitted_operations(
462+
let result = filter_operations_for_preparation(
463463
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
464464
&confirm_queue,
465465
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -483,7 +483,7 @@ async fn test_confirm_already_submitted_operations_none_submitted() {
483483
}
484484

485485
#[tokio::test]
486-
async fn test_confirm_already_submitted_operations_mixed_batch() {
486+
async fn test_filter_operations_for_preparation_mixed_batch() {
487487
let mut mock_db = MockHyperlaneDb::new();
488488
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
489489
let confirm_queue = create_test_queue();
@@ -539,7 +539,7 @@ async fn test_confirm_already_submitted_operations_mixed_batch() {
539539

540540
let batch = vec![op1, op2, op3, op4];
541541

542-
let result = confirm_already_submitted_operations(
542+
let result = filter_operations_for_preparation(
543543
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
544544
&confirm_queue,
545545
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -574,7 +574,7 @@ async fn test_confirm_already_submitted_operations_mixed_batch() {
574574
}
575575

576576
#[tokio::test]
577-
async fn test_confirm_already_submitted_operations_db_error() {
577+
async fn test_filter_operations_for_preparation_db_error() {
578578
let mut mock_db = MockHyperlaneDb::new();
579579
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
580580
let confirm_queue = create_test_queue();
@@ -597,7 +597,7 @@ async fn test_confirm_already_submitted_operations_db_error() {
597597
let op = Box::new(MockQueueOperation::with_first_prepare(message_id)) as QueueOperation;
598598
let batch = vec![op];
599599

600-
let result = confirm_already_submitted_operations(
600+
let result = filter_operations_for_preparation(
601601
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
602602
&confirm_queue,
603603
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -622,7 +622,7 @@ async fn test_confirm_already_submitted_operations_db_error() {
622622
}
623623

624624
#[tokio::test]
625-
async fn test_confirm_already_submitted_operations_payload_dropped() {
625+
async fn test_filter_operations_for_preparation_payload_dropped() {
626626
let mut mock_db = MockHyperlaneDb::new();
627627
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
628628
let confirm_queue = create_test_queue();
@@ -644,7 +644,7 @@ async fn test_confirm_already_submitted_operations_payload_dropped() {
644644
let op = Box::new(MockQueueOperation::with_first_prepare(message_id)) as QueueOperation;
645645
let batch = vec![op];
646646

647-
let result = confirm_already_submitted_operations(
647+
let result = filter_operations_for_preparation(
648648
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
649649
&confirm_queue,
650650
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -669,7 +669,7 @@ async fn test_confirm_already_submitted_operations_payload_dropped() {
669669
}
670670

671671
#[tokio::test]
672-
async fn test_confirm_already_submitted_operations_transaction_dropped() {
672+
async fn test_filter_operations_for_preparation_transaction_dropped() {
673673
let mut mock_db = MockHyperlaneDb::new();
674674
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
675675
let confirm_queue = create_test_queue();
@@ -695,7 +695,7 @@ async fn test_confirm_already_submitted_operations_transaction_dropped() {
695695
let op = Box::new(MockQueueOperation::with_first_prepare(message_id)) as QueueOperation;
696696
let batch = vec![op];
697697

698-
let result = confirm_already_submitted_operations(
698+
let result = filter_operations_for_preparation(
699699
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
700700
&confirm_queue,
701701
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -720,7 +720,7 @@ async fn test_confirm_already_submitted_operations_transaction_dropped() {
720720
}
721721

722722
#[tokio::test]
723-
async fn test_confirm_already_submitted_operations_entrypoint_error() {
723+
async fn test_filter_operations_for_preparation_entrypoint_error() {
724724
let mut mock_db = MockHyperlaneDb::new();
725725
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
726726
let confirm_queue = create_test_queue();
@@ -742,7 +742,7 @@ async fn test_confirm_already_submitted_operations_entrypoint_error() {
742742
let op = Box::new(MockQueueOperation::with_first_prepare(message_id)) as QueueOperation;
743743
let batch = vec![op];
744744

745-
let result = confirm_already_submitted_operations(
745+
let result = filter_operations_for_preparation(
746746
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
747747
&confirm_queue,
748748
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -767,7 +767,7 @@ async fn test_confirm_already_submitted_operations_entrypoint_error() {
767767
}
768768

769769
#[tokio::test]
770-
async fn test_confirm_already_submitted_operations_non_manual_retry() {
770+
async fn test_filter_operations_for_preparation_non_manual_retry() {
771771
let mut mock_db = MockHyperlaneDb::new();
772772
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
773773
let confirm_queue = create_test_queue();
@@ -794,7 +794,7 @@ async fn test_confirm_already_submitted_operations_non_manual_retry() {
794794
)) as QueueOperation;
795795
let batch = vec![op];
796796

797-
let result = confirm_already_submitted_operations(
797+
let result = filter_operations_for_preparation(
798798
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
799799
&confirm_queue,
800800
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,
@@ -818,7 +818,7 @@ async fn test_confirm_already_submitted_operations_non_manual_retry() {
818818
}
819819

820820
#[tokio::test]
821-
async fn test_confirm_already_submitted_operations_empty_payload_uuids() {
821+
async fn test_filter_operations_for_preparation_empty_payload_uuids() {
822822
let mut mock_db = MockHyperlaneDb::new();
823823
let mut mock_entrypoint = MockDispatcherEntrypoint::new();
824824
let confirm_queue = create_test_queue();
@@ -837,7 +837,7 @@ async fn test_confirm_already_submitted_operations_empty_payload_uuids() {
837837
let op = Box::new(MockQueueOperation::with_first_prepare(message_id)) as QueueOperation;
838838
let batch = vec![op];
839839

840-
let result = confirm_already_submitted_operations(
840+
let result = filter_operations_for_preparation(
841841
Arc::new(mock_entrypoint) as Arc<dyn Entrypoint + Send + Sync>,
842842
&confirm_queue,
843843
Arc::new(mock_db) as Arc<dyn HyperlaneDb>,

0 commit comments

Comments
 (0)