mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-05-29 10:16:45 +00:00

* Revert "[NOD-1500] Delete integration tests" This reverts commit fcb57a206690a884fa6afb69d5d493282954a8bf. * [NOD-1518] hashserialization -> consenusserialization * [NOD-1518] Fix add genesis to virtual * [NOD-1518] Fix a bug in SerializeCoinbasePayload. * [NOD-1518] Fix a loop error and make pastMedianTime behave correctly everywhere on genesis. * [NOD-1518] Fix another bug and an infinite loop. * [NOD-1518] Fix uninitialized slice. * [NOD-1518] Fix bad should-commit checks and another infinite loop. * [NOD-1518] Fix nil serialization. * [NOD-1518] Rename blockHash to currentBlockHash. * [NOD-1518] Move the check whether stagedVirtualUTXOSet != nil to the top of commitVirtualUTXODiff. * [NOD-1518] Simplify utxoDiffStore.Commit. * [NOD-1518] Unextract resolveBlockStatusAndCheckFinality. * [NOD-1518] Move no-transactions logic into CalculateIDMerkleRoot. * [NOD-1518] Remove redundant is-staged check. * [NOD-1518] Fix merge errors. * [NOD-1518] Don't write anything if utxoDiffChild is nil. * [NOD-1518] Stage virtualAcceptanceData and virtualMultiset. * [NOD-1518] Fix bugs in getBlockTemplate and submitBlock. * [NOD-1518] Fix bad validation order in validateHeaderInContext. * [NOD-1518] Fix bug in Next(). * [NOD-1518] Fix nil dereference of subnetworks in AddressCache. * [NOD-1518] Fix multisetStore.Get returning a pointer to a multiset that is changed in place. * [NOD-1518] Break on genesis in countSubtrees. * [NOD-1518] Fix createBlockLocator. * [NOD-1518] Fix MsgTxToDomainTransaction. * [NOD-1518] Set MaxTxVersion to 1. * [NOD-1518] Fix missing error handling, bug in MsgTxToDomainTransaction, and bad subnetwork equality check. * [NOD-1518] Fix bug in hasUTXOByOutpointFromStagedVirtualUTXODiff. * [NOD-1518] Remove irrelevant comments. * [NOD-1518] Generate transactions with sufficient fee in tx_relay_test. * [NOD-1518] Fix broken RPC handlers. * [NOD-1518] Fix merge errors. * [NOD-1518] Fix bad exists check in restorePastUTXO and missing genesis check in CalculatePastUTXOAndAcceptanceData. * [NOD-1518] Add a comment. * [NOD-1518] Use a regular mutex instead of a read-write mutex in consensus to avoid dealing with sneaky not-actually-read functions. * [NOD-1518] Fix a deadlock in GetVirtualSelectedParent. * [NOD-1518] Fix missing handler registration for CmdHeader. * [NOD-1518] Fix processHeader calling OnNewBlock and LogBlock. Also fix conversion errors in IBDRootUTXOSetAndBlock. * [NOD-1518] Fix bad Command() in MsgIBDRootUTXOSetAndBlock. * [NOD-1518] Fix bad SyncStateMissingUTXOSet logic in resolveSyncState. * [NOD-1518] Rename mode to syncState. * [NOD-1518] Fix headers-only blocks coming in after the consensus thinks it's synced. * [NOD-1518] Fix selectedChildIterator.Next not ignoring virtual, infinite loop in HashSet.Length(). * [NOD-1518] Fix not-properly wrapped IBD blocks. * [NOD-1518] Fix bad conversion in RequestIBDBlocks. * [NOD-1518] Fix bad string for CmdRequestHeaders. * [NOD-1518] Fix bad string for CmdDoneHeaders. * [NOD-1518] Fix bad Command() for MsgIBDRootNotFound. * [NOD-1518] Fix bad areHeaderTipsSyncedMaxTimeDifference value. * [NOD-1518] Add missing string for CmdRequestIBDBlocks. * [NOD-1518] Fix bad check for SyncStateMissingBlockBodies. * [NOD-1518] Fix bad timeout durations in tests. * [NOD-1518] Fix IBD blocks not calling OnNewBlock. * [NOD-1518] Change when IBD finishes. * [NOD-1518] Properly clone utxoDiffChild. * [NOD-1535] Fix reachability tests * [NOD-1518] Fix merge errors. * [NOD-1518] Move call to LogBlock to into OnNewBlock. * [NOD-1518] Return "not implemented" in unimplemented RPC handlers. * [NOD-1518] Extract cloning of hashes to a method over DomainHash. * [NOD-1518] Use isHeaderOnlyBlock. * [NOD-1518] Use constants.TransactionVersion. * [NOD-1518] Break immediately if we reached the virtual in SelectedChildIterator. * [NOD-1518] Don't stage nil utxoDiffChild. * [NOD-1518] Properly check the genesis hash in CalculatePastUTXOAndAcceptanceData. * [NOD-1518] Explain why we break on current == nil in countSubtrees. * [NOD-1518] Add a comment explaining why we check against StatusValid in resolveSyncState. * [NOD-1535] Add external reachability tests * [NOD-1535] Fix reachability tests and fix related bugs * [NOD-1535] Add setters fox reindex slack and window * [NOD-1535] Remove redundant line * [NOD-1535] Add comment * [NOD-1535] Fix comments * [NOD-1535] Rename DBReader->DatabaseContext * [NOD-1535] Check that reindex root is changed * [NOD-1535] Fix calculateNewTips Co-authored-by: Mike Zak <feanorr@gmail.com> Co-authored-by: stasatdaglabs <stas@daglabs.com>
210 lines
8.5 KiB
Go
210 lines
8.5 KiB
Go
// Copyright (c) 2014-2016 The btcsuite developers
|
|
// Use of this source code is governed by an ISC
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package dagconfig
|
|
|
|
import (
|
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/subnetworks"
|
|
"github.com/kaspanet/kaspad/domain/consensus/utils/transactionhelper"
|
|
)
|
|
|
|
var genesisTxOuts = []*externalapi.DomainTransactionOutput{}
|
|
|
|
var genesisTxPayload = []byte{
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
|
|
0x17, // Varint
|
|
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
|
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
|
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
|
}
|
|
|
|
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
|
// the main network.
|
|
var genesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1, []*externalapi.DomainTransactionInput{}, genesisTxOuts,
|
|
&subnetworks.SubnetworkIDCoinbase, 0, genesisTxPayload)
|
|
|
|
// genesisHash is the hash of the first block in the block DAG for the main
|
|
// network (genesis block).
|
|
var genesisHash = externalapi.DomainHash{
|
|
0xbb, 0xc1, 0x88, 0xdd, 0x56, 0x9d, 0x46, 0xbd,
|
|
0x36, 0xb0, 0x31, 0x52, 0x49, 0x93, 0xac, 0x70,
|
|
0x1d, 0x36, 0xf1, 0xb3, 0xd2, 0x2f, 0xe5, 0x51,
|
|
0x7c, 0x8b, 0x1a, 0xaf, 0x3c, 0x82, 0x6f, 0x18,
|
|
}
|
|
|
|
// genesisMerkleRoot is the hash of the first transaction in the genesis block
|
|
// for the main network.
|
|
var genesisMerkleRoot = externalapi.DomainHash{
|
|
0x2f, 0x55, 0x37, 0x11, 0x8a, 0x30, 0xcd, 0xcd,
|
|
0xa7, 0xdb, 0xe5, 0xe6, 0x42, 0xf9, 0x1b, 0xf3,
|
|
0xb4, 0x62, 0xd6, 0xb6, 0xed, 0xc0, 0x5c, 0xe1,
|
|
0x6e, 0xee, 0x0f, 0x3c, 0xdc, 0xf6, 0x01, 0x15,
|
|
}
|
|
|
|
// genesisBlock defines the genesis block of the block DAG which serves as the
|
|
// public transaction ledger for the main network.
|
|
var genesisBlock = externalapi.DomainBlock{
|
|
Header: &externalapi.DomainBlockHeader{
|
|
Version: 1,
|
|
ParentHashes: []*externalapi.DomainHash{},
|
|
HashMerkleRoot: genesisMerkleRoot,
|
|
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
|
UTXOCommitment: externalapi.DomainHash{},
|
|
TimeInMilliseconds: 0x175bc9e305a,
|
|
Bits: 0x207fffff,
|
|
Nonce: 0x0,
|
|
},
|
|
Transactions: []*externalapi.DomainTransaction{genesisCoinbaseTx},
|
|
}
|
|
|
|
var devnetGenesisTxOuts = []*externalapi.DomainTransactionOutput{}
|
|
|
|
var devnetGenesisTxPayload = []byte{
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
|
|
0x17, // Varint
|
|
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
|
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
|
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
|
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x64, 0x65, 0x76, 0x6e, 0x65, 0x74, // kaspa-devnet
|
|
}
|
|
|
|
// devnetGenesisCoinbaseTx is the coinbase transaction for the genesis blocks for
|
|
// the development network.
|
|
var devnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
|
[]*externalapi.DomainTransactionInput{}, devnetGenesisTxOuts,
|
|
&subnetworks.SubnetworkIDCoinbase, 0, devnetGenesisTxPayload)
|
|
|
|
// devGenesisHash is the hash of the first block in the block DAG for the development
|
|
// network (genesis block).
|
|
var devnetGenesisHash = externalapi.DomainHash{
|
|
0x92, 0xb5, 0x28, 0xd3, 0xaa, 0x6d, 0x8b, 0x30,
|
|
0x49, 0x19, 0x53, 0x6f, 0x62, 0xce, 0x9a, 0x82,
|
|
0x2f, 0x91, 0xd4, 0x33, 0x24, 0xbc, 0x39, 0xe6,
|
|
0xad, 0x53, 0xe3, 0x97, 0x5f, 0x03, 0x00, 0x00,
|
|
}
|
|
|
|
// devnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
|
// for the devopment network.
|
|
var devnetGenesisMerkleRoot = externalapi.DomainHash{
|
|
0x00, 0x94, 0xfd, 0xff, 0x4d, 0xb2, 0x4d, 0x18,
|
|
0x95, 0x21, 0x36, 0x2a, 0x14, 0xfb, 0x19, 0x7a,
|
|
0x99, 0x51, 0x7e, 0x3f, 0x44, 0xf6, 0x2e, 0x0b,
|
|
0xe7, 0xb3, 0xc0, 0xbb, 0x00, 0x3b, 0x0b, 0xbd,
|
|
}
|
|
|
|
// devnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
|
// public transaction ledger for the development network.
|
|
var devnetGenesisBlock = externalapi.DomainBlock{
|
|
Header: &externalapi.DomainBlockHeader{
|
|
Version: 1,
|
|
ParentHashes: []*externalapi.DomainHash{},
|
|
HashMerkleRoot: devnetGenesisMerkleRoot,
|
|
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
|
UTXOCommitment: externalapi.DomainHash{},
|
|
TimeInMilliseconds: 0x175bca27b7f,
|
|
Bits: 0x1e7fffff,
|
|
Nonce: 0x1a9ba,
|
|
},
|
|
Transactions: []*externalapi.DomainTransaction{devnetGenesisCoinbaseTx},
|
|
}
|
|
|
|
var simnetGenesisTxOuts = []*externalapi.DomainTransactionOutput{}
|
|
|
|
var simnetGenesisTxPayload = []byte{
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
|
|
0x17, // Varint
|
|
0xa9, 0x14, 0xda, 0x17, 0x45, 0xe9, 0xb5, 0x49, // OP-TRUE p2sh
|
|
0xbd, 0x0b, 0xfa, 0x1a, 0x56, 0x99, 0x71, 0xc7,
|
|
0x7e, 0xba, 0x30, 0xcd, 0x5a, 0x4b, 0x87,
|
|
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x73, 0x69, 0x6d, 0x6e, 0x65, 0x74, // kaspa-simnet
|
|
}
|
|
|
|
// simnetGenesisCoinbaseTx is the coinbase transaction for the simnet genesis block.
|
|
var simnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
|
[]*externalapi.DomainTransactionInput{}, simnetGenesisTxOuts,
|
|
&subnetworks.SubnetworkIDCoinbase, 0, simnetGenesisTxPayload)
|
|
|
|
// simnetGenesisHash is the hash of the first block in the block DAG for
|
|
// the simnet (genesis block).
|
|
var simnetGenesisHash = externalapi.DomainHash{
|
|
0x84, 0x96, 0x38, 0xb6, 0x5c, 0x44, 0xc0, 0xb9,
|
|
0x3c, 0x48, 0x03, 0x7c, 0x2e, 0xee, 0x0a, 0xbf,
|
|
0xfb, 0x54, 0xc8, 0x5f, 0x99, 0xd6, 0x21, 0x3d,
|
|
0x3f, 0xdd, 0xac, 0xb1, 0xe7, 0x30, 0x7e, 0x05,
|
|
}
|
|
|
|
// simnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
|
// for the devopment network.
|
|
var simnetGenesisMerkleRoot = externalapi.DomainHash{
|
|
0x79, 0x77, 0x9c, 0xad, 0x8d, 0x5a, 0x37, 0x57,
|
|
0x75, 0x8b, 0x2f, 0xa5, 0x82, 0x47, 0x2f, 0xb6,
|
|
0xbe, 0x24, 0x5f, 0xcb, 0x21, 0x68, 0x21, 0x44,
|
|
0x45, 0x39, 0x44, 0xaf, 0xab, 0x9f, 0x0f, 0xc1,
|
|
}
|
|
|
|
// simnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
|
// public transaction ledger for the development network.
|
|
var simnetGenesisBlock = externalapi.DomainBlock{
|
|
Header: &externalapi.DomainBlockHeader{
|
|
Version: 1,
|
|
ParentHashes: []*externalapi.DomainHash{},
|
|
HashMerkleRoot: simnetGenesisMerkleRoot,
|
|
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
|
UTXOCommitment: externalapi.DomainHash{},
|
|
TimeInMilliseconds: 0x175bca27c39,
|
|
Bits: 0x207fffff,
|
|
Nonce: 0x1,
|
|
},
|
|
Transactions: []*externalapi.DomainTransaction{simnetGenesisCoinbaseTx},
|
|
}
|
|
|
|
var testnetGenesisTxOuts = []*externalapi.DomainTransactionOutput{}
|
|
|
|
var testnetGenesisTxPayload = []byte{
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Blue score
|
|
0x01, // Varint
|
|
0x00, // OP-FALSE
|
|
0x6b, 0x61, 0x73, 0x70, 0x61, 0x2d, 0x74, 0x65, 0x73, 0x74, 0x6e, 0x65, 0x74, // kaspa-testnet
|
|
}
|
|
|
|
// testnetGenesisCoinbaseTx is the coinbase transaction for the testnet genesis block.
|
|
var testnetGenesisCoinbaseTx = transactionhelper.NewSubnetworkTransaction(1,
|
|
[]*externalapi.DomainTransactionInput{}, testnetGenesisTxOuts,
|
|
&subnetworks.SubnetworkIDCoinbase, 0, testnetGenesisTxPayload)
|
|
|
|
// testnetGenesisHash is the hash of the first block in the block DAG for the test
|
|
// network (genesis block).
|
|
var testnetGenesisHash = externalapi.DomainHash{
|
|
0xa9, 0xbe, 0xa7, 0xd9, 0x0f, 0xd2, 0xbd, 0xfb,
|
|
0xd8, 0x09, 0x4d, 0x6a, 0x49, 0xa7, 0x59, 0x93,
|
|
0xd1, 0x35, 0xce, 0x61, 0x18, 0x07, 0x0b, 0xe6,
|
|
0xb9, 0xec, 0xad, 0x68, 0xe4, 0x2d, 0x00, 0x00,
|
|
}
|
|
|
|
// testnetGenesisMerkleRoot is the hash of the first transaction in the genesis block
|
|
// for testnet.
|
|
var testnetGenesisMerkleRoot = externalapi.DomainHash{
|
|
0x7c, 0x5a, 0x9a, 0xb4, 0xa6, 0xd5, 0x03, 0xf3,
|
|
0x19, 0x3c, 0x26, 0x82, 0xf5, 0x45, 0xdf, 0xe3,
|
|
0x08, 0x6d, 0x94, 0xfc, 0x7d, 0xb9, 0x42, 0x4b,
|
|
0x2c, 0x38, 0xf2, 0x5c, 0x64, 0xbc, 0xb4, 0x98,
|
|
}
|
|
|
|
// testnetGenesisBlock defines the genesis block of the block DAG which serves as the
|
|
// public transaction ledger for testnet.
|
|
var testnetGenesisBlock = externalapi.DomainBlock{
|
|
Header: &externalapi.DomainBlockHeader{
|
|
Version: 1,
|
|
ParentHashes: []*externalapi.DomainHash{},
|
|
HashMerkleRoot: testnetGenesisMerkleRoot,
|
|
AcceptedIDMerkleRoot: externalapi.DomainHash{},
|
|
UTXOCommitment: externalapi.DomainHash{},
|
|
TimeInMilliseconds: 0x175bcac06ec,
|
|
Bits: 0x1e7fffff,
|
|
Nonce: 0x568f,
|
|
},
|
|
Transactions: []*externalapi.DomainTransaction{testnetGenesisCoinbaseTx},
|
|
}
|