Skip to content

Commit b84e753

Browse files
committed
Do not allow token transfers and filter out phantom txs from parse_transactions fn
Signed-off-by: Jacinta Ferrant <[email protected]>
1 parent 41c274d commit b84e753

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

testnet/stacks-node/src/tests/nakamoto_integrations.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl TestSigningChannel {
241241

242242
/// Assert that the block events captured by the test observer
243243
/// all match the miner heuristic of *exclusively* including the
244-
/// tenure change transaction and token transfers in tenure changing blocks.
244+
/// tenure change transaction in tenure changing blocks.
245245
pub fn check_nakamoto_empty_block_heuristics() {
246246
let blocks = test_observer::get_blocks();
247247
for block in blocks.iter() {
@@ -257,12 +257,10 @@ pub fn check_nakamoto_empty_block_heuristics() {
257257
let only_coinbase_and_tenure_change = txs.iter().all(|tx| {
258258
matches!(
259259
tx.payload,
260-
TransactionPayload::TenureChange(_)
261-
| TransactionPayload::Coinbase(..)
262-
| TransactionPayload::TokenTransfer(..)
260+
TransactionPayload::TenureChange(_) | TransactionPayload::Coinbase(..)
263261
)
264262
});
265-
assert!(only_coinbase_and_tenure_change, "Nakamoto blocks with a tenure change in them should only have coinbase, tenure changes, or token transfers.");
263+
assert!(only_coinbase_and_tenure_change, "Nakamoto blocks with a tenure change in them should only have coinbase or tenure changes");
266264
}
267265
}
268266
}

testnet/stacks-node/src/tests/neon_integrations.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ pub mod test_observer {
194194
use std::sync::Mutex;
195195
use std::thread;
196196

197+
use clarity::boot_util::boot_code_addr;
197198
use stacks::chainstate::stacks::boot::RewardSet;
198199
use stacks::chainstate::stacks::events::StackerDBChunksEvent;
199-
use stacks::chainstate::stacks::StacksTransaction;
200+
use stacks::chainstate::stacks::{StacksTransaction, TransactionPayload};
200201
use stacks::codec::StacksMessageCodec;
201202
use stacks::config::{EventKeyType, EventObserverConfig};
202203
use stacks::net::api::postblock_proposal::BlockValidateResponse;
@@ -578,7 +579,7 @@ pub mod test_observer {
578579
PROPOSAL_RESPONSES.lock().unwrap().clear();
579580
}
580581

581-
/// Parse the StacksTransactions from a block (does not include burn ops)
582+
/// Parse the StacksTransactions from a block (does not include burn ops or phantom txs)
582583
/// panics on any failures to parse
583584
pub fn parse_transactions(block: &serde_json::Value) -> Vec<StacksTransaction> {
584585
block
@@ -597,6 +598,14 @@ pub mod test_observer {
597598
let tx_bytes = hex_bytes(&tx_hex[2..]).unwrap();
598599
let tx =
599600
StacksTransaction::consensus_deserialize(&mut tx_bytes.as_slice()).unwrap();
601+
602+
let mainnet_address = boot_code_addr(true).into();
603+
let testnet_address = boot_code_addr(false).into();
604+
if let TransactionPayload::TokenTransfer(address, amount, _) = &tx.payload {
605+
if *address == mainnet_address || *address == testnet_address && *amount == 0 {
606+
return None;
607+
}
608+
}
600609
Some(tx)
601610
})
602611
.collect()

0 commit comments

Comments
 (0)