@@ -84,10 +84,28 @@ where
8484 task. json_output = Some ( output. output . clone ( ) ) ;
8585 task. error = output. error ;
8686 self . contracts . insert ( output. input , output. output ) ;
87+
88+ if let Some ( last_output) = self . contracts . values ( ) . last ( ) {
89+ if let Some ( contracts) = & last_output. contracts {
90+ for ( file, contracts_map) in contracts {
91+ for contract_name in contracts_map. keys ( ) {
92+ log:: debug!(
93+ "Compiled contract: {} from file: {}" ,
94+ contract_name,
95+ file
96+ ) ;
97+ }
98+ }
99+ } else {
100+ log:: warn!( "Compiled contracts field is None" ) ;
101+ }
102+ }
103+
87104 Report :: compilation ( span, T :: config_id ( ) , task) ;
88105 Ok ( ( ) )
89106 }
90107 Err ( error) => {
108+ log:: error!( "Failed to compile contract: {:?}" , error. to_string( ) ) ;
91109 task. error = Some ( error. to_string ( ) ) ;
92110 Err ( error)
93111 }
@@ -99,13 +117,40 @@ where
99117 input : & Input ,
100118 node : & T :: Blockchain ,
101119 ) -> anyhow:: Result < ( GethTrace , DiffMode ) > {
102- let receipt = node. execute_transaction ( input. legacy_transaction (
103- self . config . network_id ,
104- 0 ,
105- & self . deployed_contracts ,
106- ) ?) ?;
120+ log:: trace!( "Calling execute_input for input: {:?}" , input) ;
121+
122+ let nonce = node. fetch_add_nonce ( input. caller ) ?;
123+
124+ log:: debug!(
125+ "Nonce calculated on the execute contract, calculated nonce {}, for contract {}, having address {} on node: {}" ,
126+ & nonce,
127+ & input. instance,
128+ & input. caller,
129+ std:: any:: type_name:: <T >( )
130+ ) ;
131+
132+ let tx =
133+ match input. legacy_transaction ( self . config . network_id , nonce, & self . deployed_contracts )
134+ {
135+ Ok ( tx) => tx,
136+ Err ( err) => {
137+ log:: error!( "Failed to construct legacy transaction: {:?}" , err) ;
138+ return Err ( err) ;
139+ }
140+ } ;
141+
142+ log:: trace!( "Executing transaction for input: {:?}" , input) ;
143+
144+ let receipt = match node. execute_transaction ( tx) {
145+ Ok ( receipt) => receipt,
146+ Err ( err) => {
147+ log:: error!( "Failed to execute transaction: {:?}" , err) ;
148+ return Err ( err) ;
149+ }
150+ } ;
107151
108152 log:: trace!( "Transaction receipt: {:?}" , receipt) ;
153+
109154 let trace = node. trace_transaction ( receipt. clone ( ) ) ?;
110155 log:: trace!( "Trace result: {:?}" , trace) ;
111156
@@ -115,14 +160,28 @@ where
115160 }
116161
117162 pub fn deploy_contracts ( & mut self , input : & Input , node : & T :: Blockchain ) -> anyhow:: Result < ( ) > {
163+ log:: debug!(
164+ "Deploying contracts {}, having address {} on node: {}" ,
165+ & input. instance,
166+ & input. caller,
167+ std:: any:: type_name:: <T >( )
168+ ) ;
118169 for output in self . contracts . values ( ) {
119170 let Some ( contract_map) = & output. contracts else {
120- log:: debug!( "No contracts in output — skipping deployment for this input." ) ;
171+ log:: debug!(
172+ "No contracts in output — skipping deployment for this input {}" ,
173+ & input. instance
174+ ) ;
121175 continue ;
122176 } ;
123177
124178 for contracts in contract_map. values ( ) {
125179 for ( contract_name, contract) in contracts {
180+ log:: debug!(
181+ "Contract name is: {:?} and the input name is: {:?}" ,
182+ & contract_name,
183+ & input. instance
184+ ) ;
126185 if contract_name != & input. instance {
127186 continue ;
128187 }
@@ -134,24 +193,47 @@ where
134193 . map ( |b| b. object . clone ( ) ) ;
135194
136195 let Some ( code) = bytecode else {
137- anyhow:: bail!( "no bytecode for contract `{}`" , contract_name) ;
196+ log:: error!( "no bytecode for contract {}" , contract_name) ;
197+ continue ;
138198 } ;
139199
200+ let nonce = node. fetch_add_nonce ( input. caller ) ?;
201+
202+ log:: debug!(
203+ "Calculated nonce {}, for contract {}, having address {} on node: {}" ,
204+ & nonce,
205+ & input. instance,
206+ & input. caller,
207+ std:: any:: type_name:: <T >( )
208+ ) ;
209+
140210 let tx = TransactionRequest :: default ( )
141211 . with_from ( input. caller )
142212 . with_to ( Address :: ZERO )
143213 . with_input ( Bytes :: from ( code. clone ( ) ) )
144- . with_gas_price ( 20_000_000_000 )
145- . with_gas_limit ( 20_000_000_000 )
214+ . with_gas_price ( 5_000_000 )
215+ . with_gas_limit ( 5_000_000 )
146216 . with_chain_id ( self . config . network_id )
147- . with_nonce ( 0 ) ;
217+ . with_nonce ( nonce) ;
218+
219+ let receipt = match node. execute_transaction ( tx) {
220+ Ok ( receipt) => receipt,
221+ Err ( err) => {
222+ log:: error!(
223+ "Failed to execute transaction when deploying the contract: {:?}, {:?}" ,
224+ & contract_name,
225+ err
226+ ) ;
227+ return Err ( err) ;
228+ }
229+ } ;
148230
149- let receipt = node. execute_transaction ( tx) ?;
150231 let Some ( address) = receipt. contract_address else {
151- anyhow :: bail !(
152- "contract `{}` deployment did not return an address" ,
232+ log :: error !(
233+ "contract {} deployment did not return an address" ,
153234 contract_name
154235 ) ;
236+ continue ;
155237 } ;
156238
157239 self . deployed_contracts
@@ -161,6 +243,8 @@ where
161243 }
162244 }
163245
246+ log:: debug!( "Available contracts: {:?}" , self . deployed_contracts. keys( ) ) ;
247+
164248 Ok ( ( ) )
165249 }
166250}
@@ -227,9 +311,11 @@ where
227311
228312 for case in & self . metadata . cases {
229313 for input in & case. inputs {
314+ log:: debug!( "Starting deploying contract {}" , & input. instance) ;
230315 leader_state. deploy_contracts ( input, self . leader_node ) ?;
231316 follower_state. deploy_contracts ( input, self . follower_node ) ?;
232317
318+ log:: debug!( "Starting executing contract {}" , & input. instance) ;
233319 let ( _, leader_diff) = leader_state. execute_input ( input, self . leader_node ) ?;
234320 let ( _, follower_diff) =
235321 follower_state. execute_input ( input, self . follower_node ) ?;
0 commit comments