Skip to content
Draft
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
3 changes: 2 additions & 1 deletion stackslib/src/chainstate/stacks/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ pub struct StacksTransactionReceipt {
pub execution_cost: ExecutionCost,
pub microblock_header: Option<StacksMicroblockHeader>,
pub tx_index: u32,
/// This is really a string-formatted CheckError (which can't be clone()'ed)
/// This is really a string-formatted CheckError (which can't be clone()'ed),
/// and is not consensus critical.
pub vm_error: Option<String>,
}

Expand Down
23 changes: 22 additions & 1 deletion stackslib/src/chainstate/tests/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
use clarity::vm::costs::ExecutionCost;
use clarity::vm::types::PrincipalData;
use clarity::vm::{Value as ClarityValue, MAX_CALL_STACK_DEPTH};
use serde::{Deserialize, Serialize};
use serde::{Deserialize, Serialize, Serializer};
use stacks_common::bitvec::BitVec;

use crate::burnchains::PoxConstants;
Expand Down Expand Up @@ -152,15 +152,31 @@
network_epoch: PEER_VERSION_EPOCH_3_3,
},
])
}

Check warning on line 155 in stackslib/src/chainstate/tests/consensus.rs

View workflow job for this annotation

GitHub Actions / Rust Format

Diff in /home/runner/work/stacks-core/stacks-core/stackslib/src/chainstate/tests/consensus.rs

/// Serialize an optional string field appending a non-consensus breaking info message.
fn serialize_opt_string_ncb<S>(
value: &Option<String>,
serializer: S,
) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let original = value.clone().unwrap_or("None".to_string());
let changed = format!("{original} [NON-CONSENSUS BREAKING]");
serializer.serialize_str(&changed)
}

/// Represents the expected output of a transaction in a test.
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq)]
pub struct ExpectedTransactionOutput {
/// The expected return value of the transaction.
pub return_type: ClarityValue,
/// The expected execution cost of the transaction.
pub cost: ExecutionCost,
/// The possible Clarity VM error message associated to the transaction (non-consensus breaking)
#[serde(serialize_with = "serialize_opt_string_ncb")]
pub vm_error: Option<String>,
}

/// Represents the expected outputs for a block's execution.
Expand Down Expand Up @@ -198,6 +214,7 @@
.map(|r| ExpectedTransactionOutput {
return_type: r.result.clone(),
cost: r.execution_cost.clone(),
vm_error: r.vm_error.clone(),
})
.collect();
let total_block_cost = epoch_receipt.anchored_block_cost.clone();
Expand Down Expand Up @@ -738,6 +755,7 @@
read_count: 1,
runtime: 8114,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -763,6 +781,7 @@
read_count: 1,
runtime: 8114,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -788,6 +807,7 @@
read_count: 1,
runtime: 8114,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -813,6 +833,7 @@
read_count: 1,
runtime: 8114,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: result
read_count: 1,
runtime: 11968,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -31,6 +32,7 @@ expression: result
read_count: 3,
runtime: 499,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -56,6 +58,7 @@ expression: result
read_count: 1,
runtime: 11968,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -69,6 +72,7 @@ expression: result
read_count: 3,
runtime: 499,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -94,6 +98,7 @@ expression: result
read_count: 1,
runtime: 11968,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -107,6 +112,7 @@ expression: result
read_count: 3,
runtime: 499,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -132,6 +138,7 @@ expression: result
read_count: 1,
runtime: 11968,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -145,6 +152,7 @@ expression: result
read_count: 3,
runtime: 499,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -31,6 +32,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -44,6 +46,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -69,6 +72,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -82,6 +86,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -95,6 +100,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -120,6 +126,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -133,6 +140,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -146,6 +154,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand All @@ -171,6 +180,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -184,6 +194,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
ExpectedTransactionOutput(
return_type: Response(ResponseData(
Expand All @@ -197,6 +208,7 @@ expression: result
read_count: 0,
runtime: 0,
),
vm_error: "None [NON-CONSENSUS BREAKING]",
),
],
total_block_cost: ExecutionCost(
Expand Down
Loading