From aa297ecc1a97f26b63bd00dfd599d476a61729e4 Mon Sep 17 00:00:00 2001 From: wizeguyy Date: Mon, 2 Dec 2024 12:30:23 -0600 Subject: [PATCH] Reject blocks which emit Qi UTXOs to inactive chains --- core/block_validator.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/core/block_validator.go b/core/block_validator.go index e3743680a..84830db91 100644 --- a/core/block_validator.go +++ b/core/block_validator.go @@ -94,9 +94,21 @@ func (v *BlockValidator) ValidateBody(block *types.WorkObject) error { if hash := types.CalcUncleHash(block.Uncles()); hash != header.UncleHash() { return fmt.Errorf("uncle root hash mismatch: have %x, want %x", hash, header.UncleHash()) } - if v.hc.ProcessingState() { - if hash := types.DeriveSha(block.Transactions(), trie.NewStackTrie(nil)); hash != header.TxHash() { - return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash()) + if hash := types.DeriveSha(block.Transactions(), trie.NewStackTrie(nil)); hash != header.TxHash() { + return fmt.Errorf("transaction root hash mismatch: have %x, want %x", hash, header.TxHash()) + } + activeLocations := common.NewChainsAdded(v.hc.currentExpansionNumber) + for _, tx := range block.Transactions() { + for _, txo := range tx.TxOut() { + found := false + for _, activeLoc := range activeLocations { + if common.IsInChainScope(txo.Address, activeLoc) { + found = true + } + } + if !found { + return fmt.Errorf("Qi TXO emitted to an inactive chain") + } } } // The header view should have the etxs populated