Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2bd committed Jun 15, 2024
1 parent 95d199e commit 4c38f32
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 56 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 = 20000
future-size-threshold = 10000
1 change: 1 addition & 0 deletions linera-core/src/unit_tests/wasm_worker_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//! These tests only run if a Wasm runtime has been configured by enabling either the `wasmer` or
//! the `wasmtime` feature flags.

#![allow(clippy::large_futures)]
#![cfg(any(feature = "wasmer", feature = "wasmtime"))]

use std::sync::Arc;
Expand Down
32 changes: 17 additions & 15 deletions linera-sdk/src/test/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,15 @@ impl BlockBuilder {
/// Tries to sign the prepared [`Block`] with the [`TestValidator`]'s keys and return the
/// resulting [`Certificate`]. Returns an error if block execution fails.
pub(crate) async fn try_sign(mut self) -> anyhow::Result<(Certificate, Vec<MessageId>)> {
self.collect_incoming_messages().await;
Box::pin(self.collect_incoming_messages()).await;

let (executed_block, _) = self
.validator
.worker()
.await
.stage_block_execution(self.block)
.await?;
let (executed_block, _) = Box::pin(
self.validator
.worker()
.await
.stage_block_execution(self.block),
)
.await?;

let message_ids = (0..executed_block
.messages()
Expand Down Expand Up @@ -227,14 +228,15 @@ impl BlockBuilder {
let chain_id = self.block.chain_id;

for (message_id, action) in mem::take(&mut self.incoming_messages) {
let mut message = self
.validator
.worker()
.await
.find_incoming_message(chain_id, message_id)
.await
.expect("Failed to find message to receive in block")
.expect("Message that block should consume has not been emitted");
let mut message = Box::pin(
self.validator
.worker()
.await
.find_incoming_message(chain_id, message_id),
)
.await
.expect("Failed to find message to receive in block")
.expect("Message that block should consume has not been emitted");

message.action = action;

Expand Down
77 changes: 39 additions & 38 deletions linera-sdk/src/test/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,11 @@ impl ActiveChain {
Parameters: Serialize,
InstantiationArgument: Serialize,
{
let bytecode_location_message = if self.needs_bytecode_location(bytecode_id).await {
let bytecode_location_message = if Box::pin(self.needs_bytecode_location(bytecode_id)).await
{
self.subscribe_to_published_bytecodes_from(bytecode_id.message_id.chain_id)
.await;
Some(self.find_bytecode_location(bytecode_id).await)
Some(Box::pin(self.find_bytecode_location(bytecode_id)).await)
} else {
None
};
Expand All @@ -354,7 +355,7 @@ impl ActiveChain {
let instantiation_argument = serde_json::to_vec(&instantiation_argument).unwrap();

for &dependency in &required_application_ids {
self.register_application(dependency).await;
Box::pin(self.register_application(dependency)).await;
}

let creation_messages = self
Expand Down Expand Up @@ -385,13 +386,15 @@ impl ActiveChain {
&self,
bytecode_id: BytecodeId<Abi, Parameters, InstantiationArgument>,
) -> bool {
self.validator
.worker()
.await
.read_bytecode_location(self.id(), bytecode_id.forget_abi())
.await
.expect("Failed to check known bytecode locations")
.is_none()
Box::pin(
self.validator
.worker()
.await
.read_bytecode_location(self.id(), bytecode_id.forget_abi()),
)
.await
.expect("Failed to check known bytecode locations")
.is_none()
}

/// Finds the message that sends the message with the bytecode location of `bytecode_id`.
Expand All @@ -400,14 +403,15 @@ impl ActiveChain {
bytecode_id: BytecodeId<Abi, Parameters, InstantiationArgument>,
) -> MessageId {
for height in bytecode_id.message_id.height.0.. {
let certificate = self
.validator
.worker()
.await
.read_certificate(bytecode_id.message_id.chain_id, height.into())
.await
.expect("Failed to load certificate to search for bytecode location")
.expect("Bytecode location not found");
let certificate = Box::pin(
self.validator
.worker()
.await
.read_certificate(bytecode_id.message_id.chain_id, height.into()),
)
.await
.expect("Failed to load certificate to search for bytecode location")
.expect("Bytecode location not found");

let messages = certificate
.value()
Expand Down Expand Up @@ -438,7 +442,7 @@ impl ActiveChain {

/// Registers on this chain an application created on another chain.
pub async fn register_application<Abi>(&self, application_id: ApplicationId<Abi>) {
if self.needs_application_description(application_id).await {
if Box::pin(self.needs_application_description(application_id)).await {
let source_chain = self.validator.get_chain(&application_id.creation.chain_id);

let request_messages = self
Expand Down Expand Up @@ -469,12 +473,13 @@ impl ActiveChain {

/// Checks if the `application_id` is missing from this microchain.
async fn needs_application_description<Abi>(&self, application_id: ApplicationId<Abi>) -> bool {
let description_result = self
.validator
.worker()
.await
.describe_application(self.id(), application_id.forget_abi())
.await;
let description_result = Box::pin(
self.validator
.worker()
.await
.describe_application(self.id(), application_id.forget_abi()),
)
.await;

match description_result {
Ok(_) => false,
Expand Down Expand Up @@ -506,19 +511,15 @@ impl ActiveChain {
{
let query_bytes = serde_json::to_vec(&query).expect("Failed to serialize query");

let response = self
.validator
.worker()
.await
.query_application(
self.id(),
Query::User {
application_id: application_id.forget_abi(),
bytes: query_bytes,
},
)
.await
.expect("Failed to query application");
let response = Box::pin(self.validator.worker().await.query_application(
self.id(),
Query::User {
application_id: application_id.forget_abi(),
bytes: query_bytes,
},
))
.await
.expect("Failed to query application");

match response {
Response::User(bytes) => {
Expand Down
4 changes: 2 additions & 2 deletions linera-service/src/linera/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,7 @@ async fn run(options: ClientOptions) -> anyhow::Result<()> {
let mut wallet_state = options.create_wallet(genesis_config, *testing_prng_seed)?;
wallet_state.extend(chains);
wallet_state.save()?;
options.initialize_storage().await?;
Box::pin(options.initialize_storage()).await?;
Ok(())
}

Expand Down Expand Up @@ -1479,7 +1479,7 @@ Make sure to use a Linera client compatible with this network.
.map(|chain_id| UserChain::make_other(*chain_id, timestamp)),
);
wallet.save()?;
options.initialize_storage().await?;
Box::pin(options.initialize_storage()).await?;
if *with_new_chain {
ensure!(
faucet.is_some(),
Expand Down

0 comments on commit 4c38f32

Please sign in to comment.