@@ -5,8 +5,8 @@ use std::{mem, vec};
55
66use futures:: { FutureExt , StreamExt } ;
77use linera_base:: {
8- data_types:: { Amount , BlockHeight , Timestamp } ,
9- identifiers:: { Account , AccountOwner , BlobType , ChainId , Destination } ,
8+ data_types:: { Amount , BlockHeight } ,
9+ identifiers:: { Account , AccountOwner , BlobType , Destination } ,
1010} ;
1111use linera_views:: {
1212 context:: Context ,
@@ -60,13 +60,14 @@ where
6060 pub async fn simulate_instantiation (
6161 & mut self ,
6262 contract : UserContractCode ,
63- local_time : Timestamp ,
63+ local_time : linera_base :: data_types :: Timestamp ,
6464 application_description : ApplicationDescription ,
6565 instantiation_argument : Vec < u8 > ,
6666 contract_blob : Blob ,
6767 service_blob : Blob ,
6868 ) -> Result < ( ) , ExecutionError > {
6969 let chain_id = application_description. creator_chain_id ;
70+ assert_eq ! ( chain_id, self . context( ) . extra( ) . chain_id) ;
7071 let context = OperationContext {
7172 chain_id,
7273 authenticated_signer : None ,
@@ -106,13 +107,16 @@ where
106107 tracker,
107108 account : None ,
108109 } ;
109- let mut txn_tracker =
110- TransactionTracker :: new ( next_message_index, next_application_index, None ) ;
110+ let mut txn_tracker = TransactionTracker :: new (
111+ local_time,
112+ 0 ,
113+ next_message_index,
114+ next_application_index,
115+ None ,
116+ ) ;
111117 txn_tracker. add_created_blob ( Blob :: new_application_description ( & application_description) ) ;
112118 self . run_user_action (
113119 application_id,
114- chain_id,
115- local_time,
116120 action,
117121 context. refund_grant_to ( ) ,
118122 None ,
@@ -163,12 +167,9 @@ where
163167 C : Context + Clone + Send + Sync + ' static ,
164168 C :: Extra : ExecutionRuntimeContext ,
165169{
166- #[ expect( clippy:: too_many_arguments) ]
167170 async fn run_user_action (
168171 & mut self ,
169172 application_id : ApplicationId ,
170- chain_id : ChainId ,
171- local_time : Timestamp ,
172173 action : UserAction ,
173174 refund_grant_to : Option < Account > ,
174175 grant : Option < & mut Amount > ,
@@ -178,8 +179,6 @@ where
178179 let ExecutionRuntimeConfig { } = self . context ( ) . extra ( ) . execution_runtime_config ( ) ;
179180 self . run_user_action_with_runtime (
180181 application_id,
181- chain_id,
182- local_time,
183182 action,
184183 refund_grant_to,
185184 grant,
@@ -189,18 +188,16 @@ where
189188 . await
190189 }
191190
192- #[ expect( clippy:: too_many_arguments) ]
193191 async fn run_user_action_with_runtime (
194192 & mut self ,
195193 application_id : ApplicationId ,
196- chain_id : ChainId ,
197- local_time : Timestamp ,
198194 action : UserAction ,
199195 refund_grant_to : Option < Account > ,
200196 grant : Option < & mut Amount > ,
201197 txn_tracker : & mut TransactionTracker ,
202198 resource_controller : & mut ResourceController < Option < AccountOwner > > ,
203199 ) -> Result < ( ) , ExecutionError > {
200+ let chain_id = self . context ( ) . extra ( ) . chain_id ( ) ;
204201 let mut cloned_grant = grant. as_ref ( ) . map ( |x| * * x) ;
205202 let initial_balance = resource_controller
206203 . with_state_and_grant ( & mut self . system , cloned_grant. as_mut ( ) )
@@ -219,7 +216,6 @@ where
219216 let runtime = ContractSyncRuntime :: new (
220217 execution_state_sender,
221218 chain_id,
222- local_time,
223219 refund_grant_to,
224220 controller,
225221 & action,
@@ -257,7 +253,6 @@ where
257253 pub async fn execute_operation (
258254 & mut self ,
259255 context : OperationContext ,
260- local_time : Timestamp ,
261256 operation : Operation ,
262257 txn_tracker : & mut TransactionTracker ,
263258 resource_controller : & mut ResourceController < Option < AccountOwner > > ,
@@ -273,8 +268,6 @@ where
273268 let user_action = UserAction :: Instantiate ( context, argument) ;
274269 self . run_user_action (
275270 application_id,
276- context. chain_id ,
277- local_time,
278271 user_action,
279272 context. refund_grant_to ( ) ,
280273 None ,
@@ -290,8 +283,6 @@ where
290283 } => {
291284 self . run_user_action (
292285 application_id,
293- context. chain_id ,
294- local_time,
295286 UserAction :: Operation ( context, bytes) ,
296287 context. refund_grant_to ( ) ,
297288 None ,
@@ -307,7 +298,6 @@ where
307298 pub async fn execute_message (
308299 & mut self ,
309300 context : MessageContext ,
310- local_time : Timestamp ,
311301 message : Message ,
312302 grant : Option < & mut Amount > ,
313303 txn_tracker : & mut TransactionTracker ,
@@ -325,8 +315,6 @@ where
325315 } => {
326316 self . run_user_action (
327317 application_id,
328- context. chain_id ,
329- local_time,
330318 UserAction :: Message ( context, bytes) ,
331319 context. refund_grant_to ,
332320 grant,
@@ -362,10 +350,17 @@ where
362350 & self ,
363351 context : MessageContext ,
364352 amount : Amount ,
365- account : Account ,
366353 txn_tracker : & mut TransactionTracker ,
367354 ) -> Result < ( ) , ExecutionError > {
368355 assert_eq ! ( context. chain_id, self . context( ) . extra( ) . chain_id( ) ) ;
356+ if amount. is_zero ( ) {
357+ return Ok ( ( ) ) ;
358+ }
359+ let Some ( account) = context. refund_grant_to else {
360+ return Err ( ExecutionError :: InternalError (
361+ "Messages with grants should have a non-empty `refund_grant_to`" ,
362+ ) ) ;
363+ } ;
369364 let message = SystemMessage :: Credit {
370365 amount,
371366 source : context. authenticated_signer . unwrap_or ( AccountOwner :: CHAIN ) ,
0 commit comments