Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions crates/core/src/driver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,7 @@ where
if let Some(contracts) = &last_output.contracts {
for (file, contracts_map) in contracts {
for contract_name in contracts_map.keys() {
log::debug!(
"Compiled contract: {} from file: {}",
contract_name,
file
);
log::debug!("Compiled contract: {contract_name} from file: {file}");
}
}
} else {
Expand All @@ -118,7 +114,7 @@ where
input: &Input,
node: &T::Blockchain,
) -> anyhow::Result<(TransactionReceipt, GethTrace, DiffMode)> {
log::trace!("Calling execute_input for input: {:?}", input);
log::trace!("Calling execute_input for input: {input:?}");

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

Expand All @@ -135,12 +131,12 @@ where
{
Ok(tx) => tx,
Err(err) => {
log::error!("Failed to construct legacy transaction: {:?}", err);
log::error!("Failed to construct legacy transaction: {err:?}");
return Err(err);
}
};

log::trace!("Executing transaction for input: {:?}", input);
log::trace!("Executing transaction for input: {input:?}");

let receipt = match node.execute_transaction(tx) {
Ok(receipt) => receipt,
Expand Down Expand Up @@ -206,7 +202,7 @@ where
.map(|b| b.object.clone());

let Some(code) = bytecode else {
log::error!("no bytecode for contract {}", contract_name);
log::error!("no bytecode for contract {contract_name}");
continue;
};

Expand Down Expand Up @@ -235,31 +231,45 @@ where
Ok(receipt) => receipt,
Err(err) => {
log::error!(
"Failed to execute transaction when deploying the contract: {:?}, {:?}",
"Failed to execute transaction when deploying the contract on node : {:?}, {:?}, {:?}",
std::any::type_name::<T>(),
&contract_name,
err
);
return Err(err);
}
};

log::debug!(
"Deployment tx sent for {} with nonce {} → tx hash: {:?}, on node: {:?}",
contract_name,
nonce,
receipt.transaction_hash,
std::any::type_name::<T>(),
);

log::trace!(
"Deployed transaction receipt for contract: {} - {:?}",
"Deployed transaction receipt for contract: {} - {:?}, on node: {:?}",
&contract_name,
receipt
receipt,
std::any::type_name::<T>(),
);

let Some(address) = receipt.contract_address else {
log::error!(
"contract {} deployment did not return an address",
contract_name
"contract {contract_name} deployment did not return an address"
);
continue;
};

self.deployed_contracts
.insert(contract_name.clone(), address);
log::info!("deployed contract `{}` at {:?}", contract_name, address);
log::trace!(
"deployed contract `{}` at {:?}, on node {:?}",
contract_name,
address,
std::any::type_name::<T>()
);
}
}
}
Expand Down Expand Up @@ -297,28 +307,28 @@ where
}

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

log::trace!("{} - POST STATE:", label);
log::trace!("{label} - POST STATE:");
for (addr, state) in &diff.post {
Self::trace_account_state(" [post]", addr, state);
}
}

fn trace_account_state(prefix: &str, addr: &Address, state: &AccountState) {
log::trace!("{} 0x{:x}", prefix, addr);
log::trace!("{prefix} 0x{addr:x}");

if let Some(balance) = &state.balance {
log::trace!("{} balance: {}", prefix, balance);
log::trace!("{prefix} balance: {balance}");
}
if let Some(nonce) = &state.nonce {
log::trace!("{} nonce: {}", prefix, nonce);
log::trace!("{prefix} nonce: {nonce}");
}
if let Some(code) = &state.code {
log::trace!("{} code: {}", prefix, code);
log::trace!("{prefix} code: {code}");
}
}

Expand Down
25 changes: 15 additions & 10 deletions crates/format/src/input.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::collections::HashMap;

use alloy::{
json_abi::Function, network::TransactionBuilder, primitives::Address,
json_abi::Function,
primitives::{Address, TxKind},
rpc::types::TransactionRequest,
};
use semver::VersionReq;
Expand Down Expand Up @@ -109,17 +110,21 @@ impl Input {
deployed_contracts: &HashMap<String, Address>,
) -> anyhow::Result<TransactionRequest> {
let to = match self.method {
Method::Deployer => Address::ZERO,
_ => self.instance_to_address(&self.instance, deployed_contracts)?,
Method::Deployer => Some(TxKind::Create),
_ => Some(TxKind::Call(
self.instance_to_address(&self.instance, deployed_contracts)?,
)),
};

Ok(TransactionRequest::default()
.with_from(self.caller)
.with_to(to)
.with_nonce(nonce)
.with_chain_id(chain_id)
.with_gas_price(5_000_000)
.with_gas_limit(5_000_000))
Ok(TransactionRequest {
from: Some(self.caller),
to,
nonce: Some(nonce),
chain_id: Some(chain_id),
gas_price: Some(5_000_000),
gas: Some(5_000_000),
..Default::default()
})
}
}

Expand Down
2 changes: 1 addition & 1 deletion polkadot-sdk
Submodule polkadot-sdk updated 981 files
Loading