Skip to content

Commit

Permalink
[Consensus] panic in tests when transaction exceeds consensus size li…
Browse files Browse the repository at this point in the history
…mit (MystenLabs#19065)

## Description 

This makes the submission failure more obvious when it is due to
exceeding size limit.

## Test plan 

CI

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
mwtian authored Aug 22, 2024
1 parent ba7e085 commit 2969b59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion consensus/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use authority_node::ConsensusAuthority;
pub use block::{BlockAPI, Round};
pub use commit::{CommitDigest, CommitIndex, CommitRef, CommittedSubDag};
pub use commit_consumer::{CommitConsumer, CommitConsumerMonitor};
pub use transaction::{TransactionClient, TransactionVerifier, ValidationError};
pub use transaction::{ClientError, TransactionClient, TransactionVerifier, ValidationError};

#[cfg(test)]
#[path = "tests/randomized_tests.rs"]
Expand Down
20 changes: 16 additions & 4 deletions crates/sui-core/src/mysticeti_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
use std::{sync::Arc, time::Duration};

use arc_swap::{ArcSwapOption, Guard};
use consensus_core::TransactionClient;
use consensus_core::{ClientError, TransactionClient};
use sui_types::{
error::{SuiError, SuiResult},
messages_consensus::{ConsensusTransaction, ConsensusTransactionKind},
};
use tap::prelude::*;
use tokio::time::{sleep, Instant};
use tracing::warn;
use tracing::{error, info, warn};

use crate::{
authority::authority_per_epoch_store::AuthorityPerEpochStore,
Expand Down Expand Up @@ -92,9 +92,21 @@ impl SubmitToConsensus for LazyMysticetiClient {
.expect("Client should always be returned")
.submit(transactions_bytes)
.await
.tap_err(|r| {
.tap_err(|err| {
// Will be logged by caller as well.
warn!("Submit transactions failed with: {:?}", r);
let msg = format!("Transaction submission failed with: {:?}", err);
match err {
ClientError::ConsensusShuttingDown(_) => {
info!("{}", msg);
}
ClientError::OversizedTransaction(_, _) => {
if cfg!(debug_assertions) {
panic!("{}", msg);
} else {
error!("{}", msg);
}
}
};
})
.map_err(|err| SuiError::FailedToSubmitToConsensus(err.to_string()))?;

Expand Down

0 comments on commit 2969b59

Please sign in to comment.