Skip to content

Commit

Permalink
resolve unapproval blocks (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
hrmk1o3 authored Sep 8, 2023
1 parent 5ffabf4 commit 012052e
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "intmax"
version = "2.2.0-alpha"
version = "2.2.1-alpha"
edition = "2021"

[dependencies]
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">

![74763454](https://github.com/pucedoteth/intmax-rollup-cli/assets/119044801/2140fab8-a17b-4ae1-a95a-e8b464209e86)
<h1>intmax</h1>
<strong>The first stateless zkRollup</strong>
Expand Down Expand Up @@ -40,7 +40,7 @@ cargo run --release --bin intmax config aggregator-url https://alpha.testnet.int

```sh
alias intmax="$(pwd)/target/release/intmax"
intmax -V # intmax 2.2.0-alpha
intmax -V # intmax 2.2.1-alpha
```

## Update
Expand Down
14 changes: 13 additions & 1 deletion src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ pub async fn invoke_command(command: Command) -> anyhow::Result<()> {
println!("the above account appears replaced by {nickname}");
}

service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();
service.trigger_approve_block().await.unwrap();
}
Expand Down Expand Up @@ -918,6 +919,7 @@ pub async fn invoke_command(command: Command) -> anyhow::Result<()> {
.deposit_assets(user_address, vec![deposit_info])
.await?;

service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();
service.trigger_approve_block().await.unwrap();
}
Expand Down Expand Up @@ -1093,7 +1095,16 @@ pub async fn invoke_command(command: Command) -> anyhow::Result<()> {
}
#[cfg(feature = "advanced")]
BlockCommand::Approve {} => {
service.trigger_approve_block().await?;
match service.trigger_approve_block().await {
Ok(_) => {}
Err(error) => {
if error.to_string().contains("unexpected response from /block/approve: Validation error: proposal blocks were not found") {
println!("No proposal blocks were found");
} else {
anyhow::bail!(error);
}
}
};
}
#[cfg(feature = "advanced")]
BlockCommand::Verify { block_number } => {
Expand Down Expand Up @@ -1346,6 +1357,7 @@ pub async fn invoke_command(command: Command) -> anyhow::Result<()> {
}

// reflect to deposit tree
service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();
service.trigger_approve_block().await.unwrap();
}
Expand Down
20 changes: 20 additions & 0 deletions src/service/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,26 @@ impl ServiceBuilder {
Ok(resp)
}

pub async fn resolve_server_health_issue(&self) -> anyhow::Result<()> {
// If an error occurs in this section, there is a high likelihood that the server is down.
self.check_health().await?;

match self.trigger_approve_block().await {
Ok(_) => {}
Err(error) => {
// Approve proposal blocks when they are stuck in an unapproved state.
if !error
.to_string()
.contains("Validation error: proposal blocks were not found")
{
anyhow::bail!(error);
}
}
};

Ok(())
}

pub async fn sync_sent_transaction<
D: NodeData<WrappedHashOut<F>, WrappedHashOut<F>, WrappedHashOut<F>> + Clone,
R: RootData<WrappedHashOut<F>> + Clone,
Expand Down
3 changes: 3 additions & 0 deletions src/service/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ pub async fn merge(

wallet.backup()?;

service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();
service.trigger_approve_block().await.unwrap();
}
Expand Down Expand Up @@ -147,6 +148,7 @@ pub async fn transfer(
tx_hash
};

service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();

{
Expand Down Expand Up @@ -225,6 +227,7 @@ pub async fn bulk_mint(

service.deposit_assets(user_address, deposit_list).await?;

service.resolve_server_health_issue().await.unwrap();
service.trigger_propose_block().await.unwrap();
service.trigger_approve_block().await.unwrap();
}
Expand Down

0 comments on commit 012052e

Please sign in to comment.