Skip to content

Commit 7caa092

Browse files
committed
Some needed corrections.
1 parent 2e1ad7f commit 7caa092

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

linera-execution/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,6 @@ pub trait BaseRuntime {
735735
/// Asserts the existence of a data blob with the given hash.
736736
fn assert_data_blob_exists(&mut self, hash: DataBlobHash) -> Result<(), ExecutionError>;
737737

738-
/// Returns true if the corresponding contract uses a zero amount of storage.
739-
fn has_trivial_storage(&mut self, application: ApplicationId) -> Result<bool, ExecutionError>;
740738
}
741739

742740
pub trait ServiceRuntime: BaseRuntime {
@@ -884,6 +882,9 @@ pub trait ContractRuntime: BaseRuntime {
884882

885883
/// Writes a batch of changes.
886884
fn write_batch(&mut self, batch: Batch) -> Result<(), ExecutionError>;
885+
886+
/// Returns true if the corresponding contract uses a zero amount of storage.
887+
fn has_trivial_storage(&mut self, application: ApplicationId) -> Result<bool, ExecutionError>;
887888
}
888889

889890
/// An operation to be executed in a block.

linera-execution/src/runtime.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -898,17 +898,6 @@ where
898898
.recv_response()
899899
}
900900

901-
fn has_trivial_storage(&mut self, application: ApplicationId) -> Result<bool, ExecutionError> {
902-
let this = self.inner();
903-
let (key_size, value_size) = this
904-
.execution_state_sender
905-
.send_request(move |callback| ExecutionRequest::TotalStorageSize {
906-
application,
907-
callback,
908-
})?
909-
.recv_response()?;
910-
Ok(key_size + value_size == 0)
911-
}
912901
}
913902

914903
/// An extension trait to determine in compile time the different behaviors between contract and
@@ -1547,6 +1536,18 @@ impl ContractRuntime for ContractSyncRuntimeHandle {
15471536
.recv_response()?;
15481537
Ok(())
15491538
}
1539+
1540+
fn has_trivial_storage(&mut self, application: ApplicationId) -> Result<bool, ExecutionError> {
1541+
let this = self.inner();
1542+
let (key_size, value_size) = this
1543+
.execution_state_sender
1544+
.send_request(move |callback| ExecutionRequest::TotalStorageSize {
1545+
application,
1546+
callback,
1547+
})?
1548+
.recv_response()?;
1549+
Ok(key_size + value_size == 0)
1550+
}
15501551
}
15511552

15521553
impl ServiceSyncRuntime {

linera-execution/src/wasm/runtime_api.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,6 @@ where
231231
.map_err(|error| RuntimeError::Custom(error.into()))
232232
}
233233

234-
/// Returns true if the corresponding contract uses a non-zero amount of storage.
235-
fn has_trivial_storage(
236-
caller: &mut Caller,
237-
application: ApplicationId,
238-
) -> Result<bool, RuntimeError> {
239-
caller
240-
.user_data_mut()
241-
.runtime
242-
.has_trivial_storage(application)
243-
.map_err(|error| RuntimeError::Custom(error.into()))
244-
}
245-
246234
/// Logs a `message` with the provided information `level`.
247235
fn log(_caller: &mut Caller, message: String, level: log::Level) {
248236
match level {
@@ -681,6 +669,18 @@ where
681669
.write_batch(Batch { operations })
682670
.map_err(|error| RuntimeError::Custom(error.into()))
683671
}
672+
673+
/// Returns true if the corresponding contract uses a zero amount of storage.
674+
fn has_trivial_storage(
675+
caller: &mut Caller,
676+
application: ApplicationId,
677+
) -> Result<bool, RuntimeError> {
678+
caller
679+
.user_data_mut()
680+
.runtime
681+
.has_trivial_storage(application)
682+
.map_err(|error| RuntimeError::Custom(error.into()))
683+
}
684684
}
685685

686686
/// An implementation of the system API made available to services.

linera-sdk/src/contract/runtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165
base_wit::assert_data_blob_exists(hash.into())
166166
}
167167

168-
/// Returns true if the corresponding contract uses a non-zero amount of storage.
168+
/// Returns true if the corresponding contract uses a zero amount of storage.
169169
pub fn has_trivial_storage(&mut self, application: ApplicationId) -> bool {
170170
base_wit::has_trivial_storage(application.into())
171171
}

0 commit comments

Comments
 (0)