Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2bd committed Jun 15, 2024
1 parent 4c38f32 commit 3b91f6d
Show file tree
Hide file tree
Showing 14 changed files with 127 additions and 92 deletions.
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
stack-size-threshold = 200000
future-size-threshold = 10000
future-size-threshold = 5000
2 changes: 2 additions & 0 deletions linera-chain/src/unit_tests/chain_tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::large_futures)]

use std::{iter, sync::Arc};

use assert_matches::assert_matches;
Expand Down
23 changes: 12 additions & 11 deletions linera-core/src/chain_worker/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,7 @@ where
let local_time = self.storage.clock().current_time();
let signer = block.authenticated_signer;

let executed_block = self
.chain
.execute_block(&block, local_time, None)
let executed_block = Box::pin(self.chain.execute_block(&block, local_time, None))
.await?
.with(block);

Expand Down Expand Up @@ -344,10 +342,11 @@ where
);
self.storage.clock().sleep_until(block.timestamp).await;
let local_time = self.storage.clock().current_time();
let outcome = self
.chain
.execute_block(block, local_time, oracle_records.clone())
.await?;
let outcome = Box::pin(
self.chain
.execute_block(block, local_time, oracle_records.clone()),
)
.await?;
if let Some(lite_certificate) = &validated_block_certificate {
let value = HashedCertificateValue::new_validated(outcome.clone().with(block.clone()));
lite_certificate
Expand Down Expand Up @@ -534,10 +533,12 @@ where
// Execute the block and update inboxes.
self.chain.remove_events_from_inboxes(block).await?;
let local_time = self.storage.clock().current_time();
let verified_outcome = self
.chain
.execute_block(block, local_time, Some(oracle_records.clone()))
.await?;
let verified_outcome = Box::pin(self.chain.execute_block(
block,
local_time,
Some(oracle_records.clone()),
))
.await?;
// We should always agree on the messages and state hash.
ensure!(
*messages == verified_outcome.messages,
Expand Down
6 changes: 4 additions & 2 deletions linera-core/src/unit_tests/worker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::large_futures)]

#[path = "./wasm_worker_tests.rs"]
mod wasm;

Expand Down Expand Up @@ -157,7 +159,7 @@ async fn make_simple_transfer_certificate<S>(
worker: &WorkerState<S>,
previous_confirmed_block: Option<&Certificate>,
) -> Certificate {
make_transfer_certificate_for_epoch(
Box::pin(make_transfer_certificate_for_epoch(
chain_description,
key_pair,
None,
Expand All @@ -170,7 +172,7 @@ async fn make_simple_transfer_certificate<S>(
BTreeMap::new(),
worker,
previous_confirmed_block,
)
))
.await
}

Expand Down
11 changes: 6 additions & 5 deletions linera-explorer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ pub async fn route(app: JsValue, path: JsValue, args: JsValue) {
let msg = format!("route: {} {:?}", path.as_deref().unwrap_or("none"), args);
log_str(&msg);
let data = from_value::<Data>(app.clone()).expect("cannot parse Vue data");
route_aux(&app, &data, &path, &args, false).await
Box::pin(route_aux(&app, &data, &path, &args, false)).await
}

#[wasm_bindgen]
Expand Down Expand Up @@ -745,7 +745,8 @@ async fn subscribe_chain(app: &JsValue, address: &str, chain: ChainId) {
from_value::<Data>(app.clone()).expect("cannot parse vue data");
if let Reason::NewBlock { .. } = message_data.notifications.reason {
if message_data.notifications.chain_id == chain {
route_aux(&app, &data, &None, &Vec::new(), false).await
Box::pin(route_aux(&app, &data, &None, &Vec::new(), false))
.await
}
}
}
Expand All @@ -772,13 +773,13 @@ pub async fn start(app: JsValue) {
let default_chain = chains(&app, &address).await;
match default_chain {
Err(e) => {
route_aux(
Box::pin(route_aux(
&app,
&data,
&Some("error".to_string()),
&[("msg".to_string(), e.to_string())],
true,
)
))
.await
}
Ok(default_chain) => {
Expand Down Expand Up @@ -818,7 +819,7 @@ pub async fn start(app: JsValue) {
_ => None,
},
};
route_aux(&app, &data, &path, &args, true).await;
Box::pin(route_aux(&app, &data, &path, &args, true)).await;
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions linera-sdk/src/test/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,12 @@ impl TestValidator {
Parameters: Serialize,
InstantiationArgument: Serialize,
{
let (validator, bytecode_id) =
TestValidator::with_current_bytecode::<Abi, Parameters, InstantiationArgument>().await;
let (validator, bytecode_id) = Box::pin(TestValidator::with_current_bytecode::<
Abi,
Parameters,
InstantiationArgument,
>())
.await;

let mut creator = validator.new_chain().await;

Expand Down
4 changes: 2 additions & 2 deletions linera-service/src/linera/client_options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ impl ClientOptions {

pub async fn run_command_with_storage(self) -> anyhow::Result<()> {
let wallet = self.wallet()?;
run_with_storage(
Box::pin(run_with_storage(
self.storage_config()?
.add_common_config(self.common_config())
.await?,
&wallet.inner().genesis_config().clone(),
self.wasm_runtime.with_wasm_default(),
Job(self, wallet),
)
))
.await?;
Ok(())
}
Expand Down
8 changes: 5 additions & 3 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,9 @@ async fn run(options: ClientOptions) -> anyhow::Result<()> {
let project = Project::from_existing_project(path)?;
Ok(project.test().await?)
}
ProjectCommand::PublishAndCreate { .. } => options.run_command_with_storage().await,
ProjectCommand::PublishAndCreate { .. } => {
Box::pin(options.run_command_with_storage()).await
}
},

ClientCommand::Keygen => {
Expand Down Expand Up @@ -1485,12 +1487,12 @@ Make sure to use a Linera client compatible with this network.
faucet.is_some(),
"Using --with-new-chain requires --faucet to be set"
);
options.run_command_with_storage().await?;
Box::pin(options.run_command_with_storage()).await?;
}
Ok(())
}
},

_ => options.run_command_with_storage().await,
_ => Box::pin(options.run_command_with_storage()).await,
}
}
4 changes: 2 additions & 2 deletions linera-service/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,12 +335,12 @@ impl ProxyOptions {
let full_storage_config = self.storage_config.add_common_config(common_config).await?;
let genesis_config = GenesisConfig::read(&self.genesis_config_path)
.expect("Fail to read initial chain config");
run_with_storage(
Box::pin(run_with_storage(
full_storage_config,
&genesis_config,
None,
ProxyContext::from_options(self)?,
)
))
.await
}
}
11 changes: 8 additions & 3 deletions linera-service/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,9 +465,14 @@ async fn run(options: ServerOptions) {
.add_common_config(common_config)
.await
.unwrap();
run_with_storage(full_storage_config, &genesis_config, wasm_runtime, job)
.await
.unwrap();
Box::pin(run_with_storage(
full_storage_config,
&genesis_config,
wasm_runtime,
job,
))
.await
.unwrap();
}

ServerCommand::Generate {
Expand Down
2 changes: 2 additions & 0 deletions linera-service/src/unit_tests/chain_listener.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![allow(clippy::large_futures)]

use std::{collections::BTreeMap, sync::Arc};

use async_trait::async_trait;
Expand Down
Loading

0 comments on commit 3b91f6d

Please sign in to comment.