OSDN Git Service

ban status fail for flash swap (#512)
authorPaladz <yzhu101@uottawa.ca>
Mon, 16 Mar 2020 07:10:50 +0000 (15:10 +0800)
committerGitHub <noreply@github.com>
Mon, 16 Mar 2020 07:10:50 +0000 (15:10 +0800)
* ban status fail for flash swap

* set up init check point

Co-authored-by: paladz <453256728@qq.com>
consensus/general.go
protocol/validation/block.go

index fafda5a..9e2205b 100644 (file)
@@ -157,7 +157,8 @@ var MainNetParams = Params{
        ProducerSubsidys: []ProducerSubsidy{
                {BeginBlock: 1, EndBlock: 63072000, Subsidy: 9512938},
        },
-       SoftForkPoint: map[uint64]uint64{SoftFork001: 10461600},
+       SoftForkPoint:  map[uint64]uint64{SoftFork001: 10461600},
+       MovStartHeight: 42000000,
 }
 
 // TestNetParams is the config for vapor-testnet
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
                }