From a655bd9861b10b483627aa7deacb79b9c4b781f1 Mon Sep 17 00:00:00 2001 From: Mike Zak Date: Sun, 17 Jun 2018 14:18:23 +0300 Subject: [PATCH 1/9] [DEV-24] changed wire.BlockHeader to have list of previous hashes, instead of only 1 --- wire/blockheader.go | 59 +++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/wire/blockheader.go b/wire/blockheader.go index 5a636f36c..70183808e 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -12,19 +12,29 @@ import ( "github.com/daglabs/btcd/chaincfg/chainhash" ) -// MaxBlockHeaderPayload is the maximum number of bytes a block header can be. +// BaseBlockHeaderPayload is the base number of bytes a block header can be, +// not including the list of previous block headers. // Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes + -// PrevBlock and MerkleRoot hashes. -const MaxBlockHeaderPayload = 16 + (chainhash.HashSize * 2) +// + NumPrevBlocks 1 byte + MerkleRoot hash. +// To get total size of block header len(PrevBlocks) * chainhash.HashSize should be +// added to this value +const BaseBlockHeaderPayload = 21 + (chainhash.HashSize) + +// MaxBlockHeaderPayload is the maximum number of bytes a block header can be. +// BaseBlockHeaderPayload + up to 255 hashes of previous blocks +const MaxBlockHeaderPayload = BaseBlockHeaderPayload + (255 * chainhash.HashSize) // BlockHeader defines information about a block and is used in the bitcoin -// block (MsgBlock) and headers (MsgHeaders) messages. +// block (MsgBlock) and headers (MsgHeader ) messages. type BlockHeader struct { // Version of the block. This is not the same as the protocol version. Version int32 - // Hash of the previous block header in the block chain. - PrevBlock chainhash.Hash + // Number of entries in PrevBlocks + NumPrevBlocks byte + + // Hashes of the previous block headers in the blockDAG. + PrevBlocks []chainhash.Hash // Merkle tree reference to hash of all transactions for the block. MerkleRoot chainhash.Hash @@ -50,7 +60,7 @@ func (h *BlockHeader) BlockHash() chainhash.Hash { // transactions. Ignore the error returns since there is no way the // encode could fail except being out of memory which would cause a // run-time panic. - buf := bytes.NewBuffer(make([]byte, 0, MaxBlockHeaderPayload)) + buf := bytes.NewBuffer(make([]byte, 0, BaseBlockHeaderPayload+len(h.PrevBlocks))) _ = writeBlockHeader(buf, 0, h) return chainhash.DoubleHashH(buf.Bytes()) @@ -94,19 +104,20 @@ func (h *BlockHeader) Serialize(w io.Writer) error { // NewBlockHeader returns a new BlockHeader using the provided version, previous // block hash, merkle root hash, difficulty bits, and nonce used to generate the -// block with defaults for the remaining fields. -func NewBlockHeader(version int32, prevHash, merkleRootHash *chainhash.Hash, +// block with defaults or calclulated values for the remaining fields. +func NewBlockHeader(version int32, prevHashes []chainhash.Hash, merkleRootHash *chainhash.Hash, bits uint32, nonce uint32) *BlockHeader { // Limit the timestamp to one second precision since the protocol // doesn't support better. return &BlockHeader{ - Version: version, - PrevBlock: *prevHash, - MerkleRoot: *merkleRootHash, - Timestamp: time.Unix(time.Now().Unix(), 0), - Bits: bits, - Nonce: nonce, + Version: version, + NumPrevBlocks: byte(len(prevHashes)), + PrevBlocks: prevHashes, + MerkleRoot: *merkleRootHash, + Timestamp: time.Unix(time.Now().Unix(), 0), + Bits: bits, + Nonce: nonce, } } @@ -114,8 +125,20 @@ func NewBlockHeader(version int32, prevHash, merkleRootHash *chainhash.Hash, // decoding block headers stored to disk, such as in a database, as opposed to // decoding from the wire. func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error { - return readElements(r, &bh.Version, &bh.PrevBlock, &bh.MerkleRoot, - (*uint32Time)(&bh.Timestamp), &bh.Bits, &bh.Nonce) + err := readElements(r, &bh.Version, &bh.NumPrevBlocks) + if err != nil { + return err + } + + bh.NumPrevBlocks, err = binarySerializer.Uint8(r) + if err != nil { + return err + } + bh.PrevBlocks = make([]chainhash.Hash, bh.NumPrevBlocks) + for i := byte(0); i < bh.NumPrevBlocks; i++ { + readElement(r, &bh.PrevBlocks[i]) + } + return readElements(r, &bh.MerkleRoot, (*uint32Time)(&bh.Timestamp), &bh.Bits, &bh.Nonce) } // writeBlockHeader writes a bitcoin block header to w. See Serialize for @@ -123,6 +146,6 @@ func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error { // opposed to encoding for the wire. func writeBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error { sec := uint32(bh.Timestamp.Unix()) - return writeElements(w, bh.Version, &bh.PrevBlock, &bh.MerkleRoot, + return writeElements(w, bh.Version, bh.NumPrevBlocks, &bh.PrevBlocks, &bh.MerkleRoot, sec, bh.Bits, bh.Nonce) } From e6e9deef2289fe71a985fa7fb5065ca65998b214 Mon Sep 17 00:00:00 2001 From: Mike Zak Date: Sun, 17 Jun 2018 17:29:31 +0300 Subject: [PATCH 2/9] [DEV-14] Made MaxNumPrevBlocks a const --- wire/blockheader.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wire/blockheader.go b/wire/blockheader.go index 70183808e..99199197e 100644 --- a/wire/blockheader.go +++ b/wire/blockheader.go @@ -20,9 +20,13 @@ import ( // added to this value const BaseBlockHeaderPayload = 21 + (chainhash.HashSize) +// MaxNumPrevBlocks is the maximum number of previous blocks a block can reference. +// Currently set to 255 as the maximum number NumPrevBlocks can be due to it being a byte +const MaxNumPrevBlocks = 255 + // MaxBlockHeaderPayload is the maximum number of bytes a block header can be. -// BaseBlockHeaderPayload + up to 255 hashes of previous blocks -const MaxBlockHeaderPayload = BaseBlockHeaderPayload + (255 * chainhash.HashSize) +// BaseBlockHeaderPayload + up to MaxNumPrevBlocks hashes of previous blocks +const MaxBlockHeaderPayload = BaseBlockHeaderPayload + (MaxNumPrevBlocks * chainhash.HashSize) // BlockHeader defines information about a block and is used in the bitcoin // block (MsgBlock) and headers (MsgHeader ) messages. From f4fc50f5d9d8f88bd791b9c49af82be05e5af533 Mon Sep 17 00:00:00 2001 From: Mike Zak Date: Sun, 17 Jun 2018 17:29:57 +0300 Subject: [PATCH 3/9] [DEV-14] Fix wire tests to work with new code changes --- wire/bench_test.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/wire/bench_test.go b/wire/bench_test.go index 8ec7776d0..5f1651e21 100644 --- a/wire/bench_test.go +++ b/wire/bench_test.go @@ -409,7 +409,8 @@ func BenchmarkDecodeGetHeaders(b *testing.B) { } // BenchmarkDecodeHeaders performs a benchmark on how long it takes to -// decode a headers message with the maximum number of headers. +// decode a headers message with the maximum number of headers and maximum number of +// previous hashes per header. func BenchmarkDecodeHeaders(b *testing.B) { // Create a message with the maximum number of headers. pver := ProtocolVersion @@ -419,7 +420,15 @@ func BenchmarkDecodeHeaders(b *testing.B) { if err != nil { b.Fatalf("NewHashFromStr: unexpected error: %v", err) } - m.AddBlockHeader(NewBlockHeader(1, hash, hash, 0, uint32(i))) + prevBlocks := make([]chainhash.Hash, MaxNumPrevBlocks) + for j := byte(0); j < MaxNumPrevBlocks; j++ { + hash, err := chainhash.NewHashFromStr(fmt.Sprintf("%x%x", i, j)) + if err != nil { + b.Fatalf("NewHashFromStr: unexpected error: %v", err) + } + prevBlocks[i] = *hash + } + m.AddBlockHeader(NewBlockHeader(1, prevBlocks, hash, 0, uint32(i))) } // Serialize it so the bytes are available to test the decode below. @@ -565,7 +574,7 @@ func BenchmarkDecodeMerkleBlock(b *testing.B) { if err != nil { b.Fatalf("NewHashFromStr: unexpected error: %v", err) } - m.Header = *NewBlockHeader(1, hash, hash, 0, uint32(10000)) + m.Header = *NewBlockHeader(1, []chainhash.Hash{*hash}, hash, 0, uint32(10000)) for i := 0; i < 105; i++ { hash, err := chainhash.NewHashFromStr(fmt.Sprintf("%x", i)) if err != nil { From 5f53f1e687132e6e19649b5dfcafbc73f0f23965 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Mon, 18 Jun 2018 11:30:12 +0300 Subject: [PATCH 4/9] [DEV-28] Assigned networks to empty prevBlocks. --- chaincfg/genesis.go | 56 ++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index 3d768ad18..0f587fecf 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -31,7 +31,7 @@ var genesisCoinbaseTx = wire.MsgTx{ 0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, /* |k of sec|*/ 0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c, /* |ond bail| */ 0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, /* |out for |*/ - 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |banks| */ + 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |banks| */ }, Sequence: 0xffffffff, }, @@ -48,7 +48,7 @@ var genesisCoinbaseTx = wire.MsgTx{ 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, /* |8..U....| */ 0x12, 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, /* |..\8M...| */ 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, /* |.W.Lp+k.| */ - 0x1d, 0x5f, 0xac, /* |._.| */ + 0x1d, 0x5f, 0xac, /* |._.| */ }, }, }, @@ -77,12 +77,13 @@ var genesisMerkleRoot = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet // public transaction ledger for the main network. var genesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 - MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 18:15:05 +0000 UTC - Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] - Nonce: 0x7c2bac1d, // 2083236893 + Version: 1, + NumPrevBlocks: 0, + PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 18:15:05 +0000 UTC + Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] + Nonce: 0x7c2bac1d, // 2083236893 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -105,12 +106,13 @@ var regTestGenesisMerkleRoot = genesisMerkleRoot // as the public transaction ledger for the regression test network. var regTestGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 - MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC - Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 2, + Version: 1, + NumPrevBlocks: 0, + PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC + Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] + Nonce: 2, }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -133,12 +135,13 @@ var testNet3GenesisMerkleRoot = genesisMerkleRoot // serves as the public transaction ledger for the test network (version 3). var testNet3GenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 - MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC - Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] - Nonce: 0x18aea41a, // 414098458 + Version: 1, + NumPrevBlocks: 0, + PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC + Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] + Nonce: 0x18aea41a, // 414098458 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } @@ -161,12 +164,13 @@ var simNetGenesisMerkleRoot = genesisMerkleRoot // as the public transaction ledger for the simulation test network. var simNetGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ - Version: 1, - PrevBlock: chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 - MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1401292357, 0), // 2014-05-28 15:52:37 +0000 UTC - Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 2, + Version: 1, + NumPrevBlocks: 0, + PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b + Timestamp: time.Unix(1401292357, 0), // 2014-05-28 15:52:37 +0000 UTC + Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] + Nonce: 2, }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } From 0918d2bb129d4a15023878a40e704939c8b7a936 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 19 Jun 2018 11:59:37 +0300 Subject: [PATCH 5/9] [DEV-28] Fixed the mainnet genesis block. --- chaincfg/genesis.go | 16 +++++----- chaincfg/genesis_test.go | 68 +++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index 0f587fecf..fb7462c25 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -58,10 +58,10 @@ var genesisCoinbaseTx = wire.MsgTx{ // genesisHash is the hash of the first block in the block chain for the main // network (genesis block). var genesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. - 0x6f, 0xe2, 0x8c, 0x0a, 0xb6, 0xf1, 0xb3, 0x72, - 0xc1, 0xa6, 0xa2, 0x46, 0xae, 0x63, 0xf7, 0x4f, - 0x93, 0x1e, 0x83, 0x65, 0xe1, 0x5a, 0x08, 0x9c, - 0x68, 0xd6, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x82, 0xdc, 0xbd, 0xe6, 0x88, 0x37, 0x74, 0x5b, + 0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45, + 0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26, + 0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00, }) // genesisMerkleRoot is the hash of the first transaction in the genesis block @@ -79,11 +79,11 @@ var genesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ Version: 1, NumPrevBlocks: 0, - PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + PrevBlocks: []chainhash.Hash{}, MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(0x495fab29, 0), // 2009-01-03 18:15:05 +0000 UTC - Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] - Nonce: 0x7c2bac1d, // 2083236893 + Timestamp: time.Unix(0x5b28c4c8, 0), // 2018-06-19 08:54:32 +0000 UTC + Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] + Nonce: 0xc0192550, // 2148484547 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index d04a72f75..4099f7889 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -121,42 +121,38 @@ func TestSimNetGenesisBlock(t *testing.T) { // genesisBlockBytes are the wire encoded bytes for the genesis block of the // main network as of protocol version 60002. var genesisBlockBytes = []byte{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, /* |.....;..| */ + 0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */ + 0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */ + 0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */ + 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0xc8, 0xc4, 0x28, /* |.K.^J..(| */ + 0x5b, 0xff, 0xff, 0x00, 0x1e, 0x50, 0x25, 0x19, /* |[....P%.| */ + 0xc0, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */ - 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */ - 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */ - 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */ - 0x4b, 0x1e, 0x5e, 0x4a, 0x29, 0xab, 0x5f, 0x49, /* |K.^J)._I| */ - 0xff, 0xff, 0x00, 0x1d, 0x1d, 0xac, 0x2b, 0x7c, /* |......+|| */ - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */ - 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */ - 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */ - 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */ - 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */ - 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */ - 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */ - 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */ - 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */ - 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */ - 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */ - 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */ - 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */ - 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */ - 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */ - 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */ - 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */ - 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */ - 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ - 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ - 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */ + 0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */ + 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */ + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */ + 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */ + 0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */ + 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */ + 0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */ + 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */ + 0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */ + 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */ + 0x73, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, /* |s.......| */ + 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */ + 0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */ + 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */ + 0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */ + 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */ + 0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */ + 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */ + 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */ + 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */ + 0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */ } // regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of @@ -197,7 +193,7 @@ var regTestGenesisBlockBytes = []byte{ 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ } // testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of @@ -238,7 +234,7 @@ var testNet3GenesisBlockBytes = []byte{ 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ } // simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of @@ -279,5 +275,5 @@ var simNetGenesisBlockBytes = []byte{ 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ } From 77ee404fd1e1b8009166d7164bb232d29a0ce3a3 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 19 Jun 2018 12:03:21 +0300 Subject: [PATCH 6/9] [DEV-28] Fixed the regtest genesis block. --- chaincfg/genesis.go | 14 ++++----- chaincfg/genesis_test.go | 62 +++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index fb7462c25..eaed111bc 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -91,10 +91,10 @@ var genesisBlock = wire.MsgBlock{ // regTestGenesisHash is the hash of the first block in the block chain for the // regression test network (genesis block). var regTestGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. - 0x06, 0x22, 0x6e, 0x46, 0x11, 0x1a, 0x0b, 0x59, - 0xca, 0xaf, 0x12, 0x60, 0x43, 0xeb, 0x5b, 0xbf, - 0x28, 0xc3, 0x4f, 0x3a, 0x5e, 0x33, 0x2a, 0x1f, - 0xc7, 0xb2, 0xb7, 0x3c, 0xf1, 0x88, 0x91, 0x0f, + 0x7c, 0x03, 0x27, 0x80, 0x78, 0xfc, 0xe8, 0xed, + 0xcd, 0xfc, 0x3d, 0xe1, 0x63, 0x45, 0x4c, 0x03, + 0x0f, 0xef, 0x38, 0x16, 0xec, 0x54, 0x61, 0x6f, + 0xca, 0xc9, 0x58, 0x12, 0xb4, 0x6a, 0x15, 0x08, }) // regTestGenesisMerkleRoot is the hash of the first transaction in the genesis @@ -108,11 +108,11 @@ var regTestGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ Version: 1, NumPrevBlocks: 0, - PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + PrevBlocks: []chainhash.Hash{}, MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC + Timestamp: time.Unix(0x5b28c636, 0), // 2018-06-19 09:00:38 +0000 UTC Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 2, + Nonce: 1, }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index 4099f7889..e52664174 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -158,42 +158,38 @@ var genesisBlockBytes = []byte{ // regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of // the regression test network as of protocol version 60002. var regTestGenesisBlockBytes = []byte{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, /* |.....;..| */ + 0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */ + 0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */ + 0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */ + 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x36, 0xc6, 0x28, /* |.K.^J6.(| */ + 0x5b, 0xff, 0xff, 0x7f, 0x20, 0x01, 0x00, 0x00, /* |[... ...| */ + 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */ - 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */ - 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */ - 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */ - 0x4b, 0x1e, 0x5e, 0x4a, 0xda, 0xe5, 0x49, 0x4d, /* |K.^J)._I| */ - 0xff, 0xff, 0x7f, 0x20, 0x02, 0x00, 0x00, 0x00, /* |......+|| */ - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */ - 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */ - 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */ - 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */ - 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */ - 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */ - 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */ - 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */ - 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */ - 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */ - 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */ - 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */ - 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */ - 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */ - 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */ - 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */ - 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */ - 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */ - 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ - 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ - 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */ + 0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */ + 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */ + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */ + 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */ + 0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */ + 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */ + 0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */ + 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */ + 0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */ + 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */ + 0x73, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, /* |s.......| */ + 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */ + 0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */ + 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */ + 0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */ + 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */ + 0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */ + 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */ + 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */ + 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */ + 0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */ } // testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of From a268612dfb8e0ac3483ab443134f3f3c1abdaea3 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 19 Jun 2018 12:07:07 +0300 Subject: [PATCH 7/9] [DEV-28] Fixed the testnet genesis block. --- chaincfg/genesis.go | 14 ++++----- chaincfg/genesis_test.go | 62 +++++++++++++++++++--------------------- 2 files changed, 36 insertions(+), 40 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index eaed111bc..a423ab6b3 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -120,10 +120,10 @@ var regTestGenesisBlock = wire.MsgBlock{ // testNet3GenesisHash is the hash of the first block in the block chain for the // test network (version 3). var testNet3GenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. - 0x43, 0x49, 0x7f, 0xd7, 0xf8, 0x26, 0x95, 0x71, - 0x08, 0xf4, 0xa3, 0x0f, 0xd9, 0xce, 0xc3, 0xae, - 0xba, 0x79, 0x97, 0x20, 0x84, 0xe9, 0x0e, 0xad, - 0x01, 0xea, 0x33, 0x09, 0x00, 0x00, 0x00, 0x00, + 0x91, 0x1c, 0xe0, 0x47, 0x77, 0xad, 0x5e, 0xc5, + 0x60, 0x10, 0x21, 0x32, 0x51, 0x1b, 0x39, 0x06, + 0x24, 0xb3, 0xbf, 0x08, 0x8e, 0x04, 0x8c, 0xd3, + 0x80, 0xb4, 0x83, 0x83, 0xed, 0x00, 0x00, 0x00, }) // testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis @@ -139,9 +139,9 @@ var testNet3GenesisBlock = wire.MsgBlock{ NumPrevBlocks: 0, PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1296688602, 0), // 2011-02-02 23:16:42 +0000 UTC - Bits: 0x1d00ffff, // 486604799 [00000000ffff0000000000000000000000000000000000000000000000000000] - Nonce: 0x18aea41a, // 414098458 + Timestamp: time.Unix(0x5b28c706, 0), // 2018-06-19 09:04:06 +0000 UTC + Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] + Nonce: 0x802f1b3b, // 2150570811 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index e52664174..4a510ab1c 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -195,42 +195,38 @@ var regTestGenesisBlockBytes = []byte{ // testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of // the test network (version 3) as of protocol version 60002. var testNet3GenesisBlockBytes = []byte{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, /* |.....;..| */ + 0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */ + 0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */ + 0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */ + 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x06, 0xc7, 0x28, /* |.K.^J..(| */ + 0x5b, 0xff, 0xff, 0x00, 0x1e, 0x3b, 0x1b, 0x2f, /* |[....;./| */ + 0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */ - 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */ - 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */ - 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */ - 0x4b, 0x1e, 0x5e, 0x4a, 0xda, 0xe5, 0x49, 0x4d, /* |K.^J)._I| */ - 0xff, 0xff, 0x00, 0x1d, 0x1a, 0xa4, 0xae, 0x18, /* |......+|| */ - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */ - 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */ - 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */ - 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */ - 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */ - 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */ - 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */ - 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */ - 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */ - 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */ - 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */ - 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */ - 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */ - 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */ - 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */ - 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */ - 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */ - 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */ - 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ - 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ - 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */ + 0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */ + 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */ + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */ + 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */ + 0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */ + 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */ + 0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */ + 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */ + 0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */ + 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */ + 0x73, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, /* |s.......| */ + 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */ + 0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */ + 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */ + 0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */ + 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */ + 0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */ + 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */ + 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */ + 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */ + 0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */ } // simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of From 87084829395ee6ce53e1502bb9eea6322e5f08da Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 19 Jun 2018 12:10:46 +0300 Subject: [PATCH 8/9] [DEV-28] Fixed the simnet genesis block. --- chaincfg/genesis.go | 12 ++++---- chaincfg/genesis_test.go | 62 +++++++++++++++++++--------------------- 2 files changed, 35 insertions(+), 39 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index a423ab6b3..45be55d29 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -149,10 +149,10 @@ var testNet3GenesisBlock = wire.MsgBlock{ // simNetGenesisHash is the hash of the first block in the block chain for the // simulation test network. var simNetGenesisHash = chainhash.Hash([chainhash.HashSize]byte{ // Make go vet happy. - 0xf6, 0x7a, 0xd7, 0x69, 0x5d, 0x9b, 0x66, 0x2a, - 0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0, - 0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91, - 0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68, + 0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0, + 0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13, + 0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03, + 0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11, }) // simNetGenesisMerkleRoot is the hash of the first transaction in the genesis @@ -168,9 +168,9 @@ var simNetGenesisBlock = wire.MsgBlock{ NumPrevBlocks: 0, PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b - Timestamp: time.Unix(1401292357, 0), // 2014-05-28 15:52:37 +0000 UTC + Timestamp: time.Unix(0x5b28c7ec, 0), // 2018-06-19 09:07:56 +0000 UTC Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000] - Nonce: 2, + Nonce: 0x9ffffffb, // 2684354555 }, Transactions: []*wire.MsgTx{&genesisCoinbaseTx}, } diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index 4a510ab1c..c336c1bcb 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -232,40 +232,36 @@ var testNet3GenesisBlockBytes = []byte{ // simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of // the simulation test network as of protocol version 70002. var simNetGenesisBlockBytes = []byte{ - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ + 0x01, 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, /* |.....;..| */ + 0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */ + 0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */ + 0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */ + 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0xec, 0xc7, 0x28, /* |.K.^J..(| */ + 0x5b, 0xff, 0xff, 0x7f, 0x20, 0xfb, 0xff, 0xff, /* |[... ...| */ + 0x9f, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x3b, 0xa3, 0xed, 0xfd, /* |....;...| */ - 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, 0x3e, /* |z{..z.,>| */ - 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, 0xc3, /* |gv.a....| */ - 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, 0xaa, /* |..Q2:...| */ - 0x4b, 0x1e, 0x5e, 0x4a, 0x45, 0x06, 0x86, 0x53, /* |K.^J)._I| */ - 0xff, 0xff, 0x7f, 0x20, 0x02, 0x00, 0x00, 0x00, /* |......+|| */ - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */ - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, /* |........| */ - 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, 0x1d, /* |..M.....| */ - 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, /* |..EThe T| */ - 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, 0x2f, /* |imes 03/| */ - 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, /* |Jan/2009| */ - 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, 0x6c, /* | Chancel| */ - 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, /* |lor on b| */ - 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, 0x20, /* |rink of | */ - 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, /* |second b| */ - 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, 0x66, /* |ailout f| */ - 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, /* |or banks| */ - 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, /* |........| */ - 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, 0x04, /* |*....CA.| */ - 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, /* |g....UH'| */ - 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, 0x10, /* |.g..q0..| */ - 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, /* |\..(.9..| */ - 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, 0xb6, /* |yb...a..| */ - 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, /* |I..?L.8.| */ - 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, 0xde, /* |.U......| */ - 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, /* |\8M....W| */ - 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, 0x5f, /* |.Lp+k.._|*/ - 0xac, 0x00, 0x00, 0x00, 0x00, /* |.....| */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */ + 0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */ + 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */ + 0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */ + 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */ + 0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */ + 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */ + 0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */ + 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */ + 0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */ + 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */ + 0x73, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, /* |s.......| */ + 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */ + 0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */ + 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */ + 0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */ + 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */ + 0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */ + 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */ + 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */ + 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */ + 0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */ } From 4457a49f549be1f33253f031f3473bab40218835 Mon Sep 17 00:00:00 2001 From: Stas Boutenko Date: Tue, 19 Jun 2018 12:46:42 +0300 Subject: [PATCH 9/9] [DEV-28] Forgot to remove a couple of not-relevant comments. --- chaincfg/genesis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index 45be55d29..e2160fda4 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -137,7 +137,7 @@ var testNet3GenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ Version: 1, NumPrevBlocks: 0, - PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + PrevBlocks: []chainhash.Hash{}, MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b Timestamp: time.Unix(0x5b28c706, 0), // 2018-06-19 09:04:06 +0000 UTC Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000] @@ -166,7 +166,7 @@ var simNetGenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ Version: 1, NumPrevBlocks: 0, - PrevBlocks: []chainhash.Hash{}, // 0000000000000000000000000000000000000000000000000000000000000000 + PrevBlocks: []chainhash.Hash{}, MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b Timestamp: time.Unix(0x5b28c7ec, 0), // 2018-06-19 09:07:56 +0000 UTC Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]