Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions deployments/deployments.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2018 The Decred developers
// Copyright (c) 2018-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand All @@ -22,7 +22,6 @@ import (
// active, not when it is inactive.
type HardcodedDeployment struct {
MainNetActivationHeight int32
TestNet2ActivationHeight int32
TestNet3ActivationHeight int32
SimNetActivationHeight int32
}
Expand All @@ -31,7 +30,6 @@ type HardcodedDeployment struct {
// defined by https://github.com/decred/dcps/blob/master/dcp-0001/dcp-0001.mediawiki.
var DCP0001 = HardcodedDeployment{
MainNetActivationHeight: 149248,
TestNet2ActivationHeight: 46128,
TestNet3ActivationHeight: 0,
SimNetActivationHeight: 0,
}
Expand All @@ -40,7 +38,6 @@ var DCP0001 = HardcodedDeployment{
// https://github.com/decred/dcps/blob/master/dcp-0002/dcp-0002.mediawiki.
var DCP0002 = HardcodedDeployment{
MainNetActivationHeight: 189568,
TestNet2ActivationHeight: 151968,
TestNet3ActivationHeight: 0,
SimNetActivationHeight: 0,
}
Expand All @@ -49,7 +46,14 @@ var DCP0002 = HardcodedDeployment{
// https://github.com/decred/dcps/blob/master/dcp-0003/dcp-0003.mediawiki.
var DCP0003 = HardcodedDeployment{
MainNetActivationHeight: 189568,
TestNet2ActivationHeight: 151968,
TestNet3ActivationHeight: 0,
SimNetActivationHeight: 0,
}

// DCP0005 specifies the activation of a block header commitments soft fork as
// defined by https://github.com/decred/dcps/blob/master/dcp-0005/dcp-0005.mediawiki.
var DCP0005 = HardcodedDeployment{
MainNetActivationHeight: 431488,
TestNet3ActivationHeight: 0,
SimNetActivationHeight: 0,
}
Expand All @@ -62,8 +66,6 @@ func (d *HardcodedDeployment) Active(height int32, net wire.CurrencyNet) bool {
switch net {
case wire.MainNet:
activationHeight = d.MainNetActivationHeight
case 0x48e7a065: // testnet2
activationHeight = d.TestNet2ActivationHeight
case wire.TestNet3:
activationHeight = d.TestNet3ActivationHeight
case wire.SimNet:
Expand Down
14 changes: 9 additions & 5 deletions spv/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"sync"
"time"

"decred.org/dcrwallet/v5/deployments"
"decred.org/dcrwallet/v5/errors"
"decred.org/dcrwallet/v5/p2p"
"decred.org/dcrwallet/v5/validate"
Expand Down Expand Up @@ -64,7 +65,8 @@ func pickForGetCfilters(lastHeaderHeight int32) func(rp *p2p.RemotePeer) bool {
// the block match what is promised by the merkle commitment in the block
// header. The remote peer is disconnected if it returns a block that fails
// this verification.
func blocksFromPeer(ctx context.Context, rp *p2p.RemotePeer, blockHashes []*chainhash.Hash) ([]*wire.MsgBlock, error) {
func blocksFromPeer(ctx context.Context, rp *p2p.RemotePeer,
blockHashes []*chainhash.Hash, net wire.CurrencyNet) ([]*wire.MsgBlock, error) {
blocks, err := rp.Blocks(ctx, blockHashes)
if err != nil {
return nil, err
Expand All @@ -79,9 +81,11 @@ func blocksFromPeer(ctx context.Context, rp *p2p.RemotePeer, blockHashes []*chai
// request. Every block obtained from a remote peer must therefore have
// its transaction trees checked against the merkle root commitments of
// the header before the transactions are used for anything.
err := validate.MerkleRoots(b)
if err != nil {
var err error
if deployments.DCP0005.Active(int32(b.Header.Height), net) {
err = validate.DCP0005MerkleRoot(b)
} else {
err = validate.MerkleRoots(b)
}
if err != nil {
rp.Disconnect(err)
Expand All @@ -101,7 +105,7 @@ func (s *Syncer) Blocks(ctx context.Context, blockHashes []*chainhash.Hash) ([]*
if err != nil {
return nil, err
}
blocks, err := blocksFromPeer(ctx, rp, blockHashes)
blocks, err := blocksFromPeer(ctx, rp, blockHashes, s.wallet.ChainParams().Net)
if err != nil {
log.Debugf("Unable to fetch blocks from %v: %v", rp, err)
continue
Expand Down Expand Up @@ -587,7 +591,7 @@ func (s *Syncer) Rescan(ctx context.Context, blockHashes []chainhash.Hash, save
return err
}

blocks, err := blocksFromPeer(ctx, rp, fmatches)
blocks, err := blocksFromPeer(ctx, rp, fmatches, s.wallet.ChainParams().Net)
if err != nil {
continue PickPeer
}
Expand Down
4 changes: 2 additions & 2 deletions spv/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ func (s *Syncer) handleBlockInvs(ctx context.Context, rp *p2p.RemotePeer, hashes
return nil
}

blocks, err := blocksFromPeer(ctx, rp, hashes)
blocks, err := blocksFromPeer(ctx, rp, hashes, s.wallet.ChainParams().Net)
if err != nil {
op := errors.Opf(opf, rp)
return errors.E(op, err)
Expand Down Expand Up @@ -1349,7 +1349,7 @@ func (s *Syncer) scanChain(ctx context.Context, rp *p2p.RemotePeer, chain []*wal
wg.Wait()

if len(fmatches) != 0 {
blocks, err := blocksFromPeer(ctx, rp, fmatches)
blocks, err := blocksFromPeer(ctx, rp, fmatches, s.wallet.ChainParams().Net)
if err != nil {
return nil, err
}
Expand Down
2 changes: 0 additions & 2 deletions wallet/createtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ func (w *Wallet) txToMultisigInternal(ctx context.Context, op errors.Op, dbtx wa
switch w.chainParams.Net {
case wire.MainNet:
feeEstForTx = 5e7
case 0x48e7a065: // testnet2
feeEstForTx = 5e7
case wire.TestNet3:
feeEstForTx = 5e7
default:
Expand Down
2 changes: 0 additions & 2 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,6 @@ func voteVersion(params *chaincfg.Params) uint32 {
switch params.Net {
case wire.MainNet:
return 11
case 0x48e7a065: // TestNet2
return 6
case wire.TestNet3:
return 12
case wire.SimNet:
Expand Down
4 changes: 1 addition & 3 deletions walletsetup.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2014-2015 The btcsuite developers
// Copyright (c) 2015-2024 The Decred developers
// Copyright (c) 2015-2026 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -35,8 +35,6 @@ func networkDir(dataDir string, chainParams *chaincfg.Params) string {
netname := chainParams.Name
// Be cautious of v2+ testnets being named only "testnet".
switch chainParams.Net {
case 0x48e7a065: // testnet2
netname = "testnet2"
case wire.TestNet3:
netname = "testnet3"
}
Expand Down
Loading