OSDN Git Service

ban status fail for flash swap ban_status_fail
authorpaladz <453256728@qq.com>
Mon, 16 Mar 2020 06:38:57 +0000 (14:38 +0800)
committerpaladz <453256728@qq.com>
Mon, 16 Mar 2020 06:38:57 +0000 (14:38 +0800)
protocol/validation/block.go

index 4292014..9be89a0 100644 (file)
@@ -101,6 +101,13 @@ func ValidateBlock(b *bc.Block, parent *types.BlockHeader, rewards []state.Coinb
                        return errors.Wrapf(validateResult.err, "validate of transaction %d of %d", i, len(b.Transactions))
                }
 
+               // for support flash swap running on vapor, status fail txs need to be
+               // rejected. Or the attacker can steal BTM from any BTM/* trade pair by
+               // using status fail charge fee rule.
+               if b.Height >= consensus.ActiveNetParams.MovStartHeight && validateResult.err != nil {
+                       return errors.New("the chain currently didn't support status fail tx")
+               }
+
                if err := b.TransactionStatus.SetStatus(i, validateResult.err != nil); err != nil {
                        return err
                }