Skip to content
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

Handle failed transactions/blocks #2120

Merged
merged 19 commits into from
Mar 28, 2024

Conversation

Thoralf-M
Copy link
Member

@Thoralf-M Thoralf-M commented Mar 4, 2024

Description of change

Handle issues from posting the block, if we can't get it posted 3 times, we will return None for the block id and during syncing when we also can't get the block, we will set the tx state as conflicting and unlock its inputs so they're available for new transactions again.

Links to any relevant issues

#2111

Type of change

  • Bug fix (a non-breaking change which fixes an issue)

How the change has been tested

cli wallet and

#[tokio::test]
async fn send_amount_in_loop() -> Result<(), Box<dyn std::error::Error>> {
    let logger_output_config = fern_logger::LoggerOutputConfigBuilder::new()
        .name("wallet.log")
        .target_exclusions(&["h2", "hyper", "rustls"])
        .level_filter(log::LevelFilter::Debug);
    let config = fern_logger::LoggerConfig::build()
        .with_output(logger_output_config)
        .finish();
    fern_logger::logger_init(config).unwrap();

    let storage_path = "test-storage/send_amount";
    setup(storage_path)?;

    println!("Creating wallet with block issuer account...");
    let wallet_0 = make_wallet(storage_path, None, None).await?;
    request_funds(&wallet_0).await?;

    for i in 0..1000 {
        match wallet_0
            .send_with_params([SendParams::new(1_000_000, wallet_0.address().await)?], None)
            .await
        {
            Ok(tx) => {
                println!("Sent tx {i}");
                if let Some(block_id) = tx.block_id {
                    println!(" in block {block_id}");
                    wallet_0
                        .wait_for_transaction_acceptance(&tx.transaction_id, None, None)
                        .await?;
                }
            }
            Err(err) => {
                println!("{err:?}");
            }
        }
        wallet_0.sync(None).await.unwrap();
    }

    tear_down(storage_path)
}

with a modified operations/block.rs so we get the case where no block was sent

        let block_id = if crate::types::block::rand::bool::rand_bool() {
            self.client().post_block(&block).await?
        } else {
            // Just so it returns an error for testing, not relevant
            return Err(WalletError::InvalidVotingPower);
        };

@thibault-martinez thibault-martinez linked an issue Mar 4, 2024 that may be closed by this pull request
@Thoralf-M Thoralf-M marked this pull request as ready for review March 26, 2024 17:57
@Thoralf-M Thoralf-M changed the title Handle BlockState::Failed Handle failed transactions/blocks Mar 26, 2024
DaughterOfMars
DaughterOfMars previously approved these changes Mar 27, 2024
Alex6323
Alex6323 previously approved these changes Mar 28, 2024
@Alex6323 Alex6323 dismissed their stale review March 28, 2024 11:24

unresolved convos

@DaughterOfMars DaughterOfMars merged commit 001588e into iotaledger:2.0 Mar 28, 2024
37 checks passed
@Thoralf-M Thoralf-M deleted the failed-transaction-handling branch March 28, 2024 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle potential problems from submitting blocks
4 participants