From fd328c383d095d60de4e8cb4386dd04cd0b8f048 Mon Sep 17 00:00:00 2001 From: Paladz Date: Mon, 16 Mar 2020 15:10:50 +0800 Subject: [PATCH] ban status fail for flash swap (#512) * ban status fail for flash swap * set up init check point Co-authored-by: paladz <453256728@qq.com> --- consensus/general.go | 3 ++- protocol/validation/block.go | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/consensus/general.go b/consensus/general.go index fafda5ad..9e2205bd 100644 --- a/consensus/general.go +++ b/consensus/general.go @@ -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 diff --git a/protocol/validation/block.go b/protocol/validation/block.go index 42920141..9be89a07 100644 --- a/protocol/validation/block.go +++ b/protocol/validation/block.go @@ -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 } -- 2.11.0