Skip to content

Commit

Permalink
Merge pull request stacks-network#3816 from stacks-network/feat/contr…
Browse files Browse the repository at this point in the history
…act-error-txid

Add txid to contract deploy logs
  • Loading branch information
kantai authored Aug 7, 2023
2 parents fe9c70a + 4073384 commit eca1cfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to the versioning scheme outlined in the [README.md](README.md).

## [2.4.0.0.1]

This is a minor change to add `txid` fields into the log messages from failing
contract deploys. This will help tools (and users) more easily find the log
messages to determine what went wrong.

## [2.4.0.0.0]
This is a **consensus-breaking** release to revert consensus to PoX, and is the second fork proposed in SIP-022.

Expand Down
5 changes: 5 additions & 0 deletions src/chainstate/stacks/db/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1133,6 +1133,7 @@ impl StacksChainState {
warn!(
"Runtime error in contract analysis for {}: {:?}",
&contract_id, &other_error;
"txid" => %tx.txid(),
"AST rules" => %format!("{:?}", &ast_rules)
);
let receipt = StacksTransactionReceipt::from_analysis_failure(
Expand Down Expand Up @@ -1187,6 +1188,7 @@ impl StacksChainState {
Err(e) => match handle_clarity_runtime_error(e) {
ClarityRuntimeTxError::Acceptable { error, err_type } => {
info!("Smart-contract processed with {}", err_type;
"txid" => %tx.txid(),
"contract" => %contract_id,
"code" => %contract_code_str,
"error" => ?error);
Expand Down Expand Up @@ -1215,6 +1217,7 @@ impl StacksChainState {
// in 2.1 and later, this is a permitted runtime error. take the
// fee from the payer and keep the tx.
warn!("Smart-contract encountered an analysis error at runtime";
"txid" => %tx.txid(),
"contract" => %contract_id,
"code" => %contract_code_str,
"error" => %check_error);
Expand All @@ -1230,6 +1233,7 @@ impl StacksChainState {
} else {
// prior to 2.1, this is not permitted in a block.
warn!("Unexpected analysis error invalidating transaction: if included, this will invalidate a block";
"txid" => %tx.txid(),
"contract" => %contract_id,
"code" => %contract_code_str,
"error" => %check_error);
Expand All @@ -1240,6 +1244,7 @@ impl StacksChainState {
}
ClarityRuntimeTxError::Rejectable(e) => {
error!("Unexpected error invalidating transaction: if included, this will invalidate a block";
"txid" => %tx.txid(),
"contract_name" => %contract_id,
"code" => %contract_code_str,
"error" => ?e);
Expand Down

0 comments on commit eca1cfe

Please sign in to comment.