Skip to content

Commit 3a537c2

Browse files
Added extra logging for critical part of the flow. (#27)
* Fix legacy_transaction to address for execution part * updated polkadot-sdk to latest * Update polkadot-sdk to latest main with fixes * Added extra logging * Applied some clippy improvements
1 parent 4ab79ed commit 3a537c2

File tree

3 files changed

+47
-32
lines changed

3 files changed

+47
-32
lines changed

crates/core/src/driver/mod.rs

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,7 @@ where
9090
if let Some(contracts) = &last_output.contracts {
9191
for (file, contracts_map) in contracts {
9292
for contract_name in contracts_map.keys() {
93-
log::debug!(
94-
"Compiled contract: {} from file: {}",
95-
contract_name,
96-
file
97-
);
93+
log::debug!("Compiled contract: {contract_name} from file: {file}");
9894
}
9995
}
10096
} else {
@@ -118,7 +114,7 @@ where
118114
input: &Input,
119115
node: &T::Blockchain,
120116
) -> anyhow::Result<(TransactionReceipt, GethTrace, DiffMode)> {
121-
log::trace!("Calling execute_input for input: {:?}", input);
117+
log::trace!("Calling execute_input for input: {input:?}");
122118

123119
let nonce = node.fetch_add_nonce(input.caller)?;
124120

@@ -135,12 +131,12 @@ where
135131
{
136132
Ok(tx) => tx,
137133
Err(err) => {
138-
log::error!("Failed to construct legacy transaction: {:?}", err);
134+
log::error!("Failed to construct legacy transaction: {err:?}");
139135
return Err(err);
140136
}
141137
};
142138

143-
log::trace!("Executing transaction for input: {:?}", input);
139+
log::trace!("Executing transaction for input: {input:?}");
144140

145141
let receipt = match node.execute_transaction(tx) {
146142
Ok(receipt) => receipt,
@@ -206,7 +202,7 @@ where
206202
.map(|b| b.object.clone());
207203

208204
let Some(code) = bytecode else {
209-
log::error!("no bytecode for contract {}", contract_name);
205+
log::error!("no bytecode for contract {contract_name}");
210206
continue;
211207
};
212208

@@ -235,31 +231,45 @@ where
235231
Ok(receipt) => receipt,
236232
Err(err) => {
237233
log::error!(
238-
"Failed to execute transaction when deploying the contract: {:?}, {:?}",
234+
"Failed to execute transaction when deploying the contract on node : {:?}, {:?}, {:?}",
235+
std::any::type_name::<T>(),
239236
&contract_name,
240237
err
241238
);
242239
return Err(err);
243240
}
244241
};
245242

243+
log::debug!(
244+
"Deployment tx sent for {} with nonce {} → tx hash: {:?}, on node: {:?}",
245+
contract_name,
246+
nonce,
247+
receipt.transaction_hash,
248+
std::any::type_name::<T>(),
249+
);
250+
246251
log::trace!(
247-
"Deployed transaction receipt for contract: {} - {:?}",
252+
"Deployed transaction receipt for contract: {} - {:?}, on node: {:?}",
248253
&contract_name,
249-
receipt
254+
receipt,
255+
std::any::type_name::<T>(),
250256
);
251257

252258
let Some(address) = receipt.contract_address else {
253259
log::error!(
254-
"contract {} deployment did not return an address",
255-
contract_name
260+
"contract {contract_name} deployment did not return an address"
256261
);
257262
continue;
258263
};
259264

260265
self.deployed_contracts
261266
.insert(contract_name.clone(), address);
262-
log::info!("deployed contract `{}` at {:?}", contract_name, address);
267+
log::trace!(
268+
"deployed contract `{}` at {:?}, on node {:?}",
269+
contract_name,
270+
address,
271+
std::any::type_name::<T>()
272+
);
263273
}
264274
}
265275
}
@@ -297,28 +307,28 @@ where
297307
}
298308

299309
pub fn trace_diff_mode(label: &str, diff: &DiffMode) {
300-
log::trace!("{} - PRE STATE:", label);
310+
log::trace!("{label} - PRE STATE:");
301311
for (addr, state) in &diff.pre {
302312
Self::trace_account_state(" [pre]", addr, state);
303313
}
304314

305-
log::trace!("{} - POST STATE:", label);
315+
log::trace!("{label} - POST STATE:");
306316
for (addr, state) in &diff.post {
307317
Self::trace_account_state(" [post]", addr, state);
308318
}
309319
}
310320

311321
fn trace_account_state(prefix: &str, addr: &Address, state: &AccountState) {
312-
log::trace!("{} 0x{:x}", prefix, addr);
322+
log::trace!("{prefix} 0x{addr:x}");
313323

314324
if let Some(balance) = &state.balance {
315-
log::trace!("{} balance: {}", prefix, balance);
325+
log::trace!("{prefix} balance: {balance}");
316326
}
317327
if let Some(nonce) = &state.nonce {
318-
log::trace!("{} nonce: {}", prefix, nonce);
328+
log::trace!("{prefix} nonce: {nonce}");
319329
}
320330
if let Some(code) = &state.code {
321-
log::trace!("{} code: {}", prefix, code);
331+
log::trace!("{prefix} code: {code}");
322332
}
323333
}
324334

crates/format/src/input.rs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::collections::HashMap;
22

33
use alloy::{
4-
json_abi::Function, network::TransactionBuilder, primitives::Address,
4+
json_abi::Function,
5+
primitives::{Address, TxKind},
56
rpc::types::TransactionRequest,
67
};
78
use semver::VersionReq;
@@ -109,17 +110,21 @@ impl Input {
109110
deployed_contracts: &HashMap<String, Address>,
110111
) -> anyhow::Result<TransactionRequest> {
111112
let to = match self.method {
112-
Method::Deployer => Address::ZERO,
113-
_ => self.instance_to_address(&self.instance, deployed_contracts)?,
113+
Method::Deployer => Some(TxKind::Create),
114+
_ => Some(TxKind::Call(
115+
self.instance_to_address(&self.instance, deployed_contracts)?,
116+
)),
114117
};
115118

116-
Ok(TransactionRequest::default()
117-
.with_from(self.caller)
118-
.with_to(to)
119-
.with_nonce(nonce)
120-
.with_chain_id(chain_id)
121-
.with_gas_price(5_000_000)
122-
.with_gas_limit(5_000_000))
119+
Ok(TransactionRequest {
120+
from: Some(self.caller),
121+
to,
122+
nonce: Some(nonce),
123+
chain_id: Some(chain_id),
124+
gas_price: Some(5_000_000),
125+
gas: Some(5_000_000),
126+
..Default::default()
127+
})
123128
}
124129
}
125130

polkadot-sdk

Submodule polkadot-sdk updated 981 files

0 commit comments

Comments
 (0)