diff --git a/common/proto_common.pb.go b/common/proto_common.pb.go index 5f399f33fc..03f6083d24 100644 --- a/common/proto_common.pb.go +++ b/common/proto_common.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc-gen-go v1.30.0 +// protoc v4.25.1 // source: common/proto_common.proto package common diff --git a/core/rawdb/db.pb.go b/core/rawdb/db.pb.go index 1d7c41b6a5..7c4dabda26 100644 --- a/core/rawdb/db.pb.go +++ b/core/rawdb/db.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc-gen-go v1.30.0 +// protoc v4.25.1 // source: core/rawdb/db.proto package rawdb diff --git a/core/types/block.go b/core/types/block.go index 78eab761d0..5de787c3ff 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -29,6 +29,7 @@ import ( "sync/atomic" "time" + "google.golang.org/protobuf/proto" "lukechampine.com/blake3" "github.com/dominant-strategies/go-quai/common" @@ -358,7 +359,12 @@ func (h *Header) ProtoDecode(protoHeader *ProtoHeader) error { } h.SetUncleHash(common.BytesToHash(protoHeader.GetUncleHash().GetValue())) - h.SetCoinbase(common.BytesToAddress(protoHeader.GetCoinbase(), protoHeader.GetLocation().GetValue())) + // If there is no coinbase, its a genesis block and have to be treated differently + if len(protoHeader.Coinbase) != 0 { + h.SetCoinbase(common.BytesToAddress(protoHeader.GetCoinbase(), protoHeader.GetLocation().GetValue())) + } else { + h.SetCoinbase(common.Address{}) + } h.SetRoot(common.BytesToHash(protoHeader.GetRoot().GetValue())) h.SetTxHash(common.BytesToHash(protoHeader.GetTxHash().GetValue())) h.SetReceiptHash(common.BytesToHash(protoHeader.GetReceiptHash().GetValue())) @@ -582,10 +588,8 @@ func (h *Header) SetTime(val uint64) { func (h *Header) SetExtra(val []byte) { h.hash = atomic.Value{} // clear hash cache h.sealHash = atomic.Value{} // clear sealHash cache - if len(val) > 0 { - h.extra = make([]byte, len(val)) - copy(h.extra, val) - } + h.extra = make([]byte, len(val)) + copy(h.extra, val) } func (h *Header) SetMixHash(val common.Hash) { h.hash = atomic.Value{} // clear hash cache @@ -601,27 +605,51 @@ func (h *Header) ParentHashArray() []common.Hash { return h.parentHash } func (h *Header) ManifestHashArray() []common.Hash { return h.manifestHash } func (h *Header) NumberArray() []*big.Int { return h.number } -// headerData comprises all data fields of the header, excluding the nonce, so -// that the nonce may be independently adjusted in the work algorithm. -type sealData struct { - ParentHash []common.Hash - UncleHash common.Hash - Coinbase common.Address - Root common.Hash - TxHash common.Hash - EtxHash common.Hash - EtxRollupHash common.Hash - ManifestHash []common.Hash - ReceiptHash common.Hash - Number []*big.Int - GasLimit uint64 - GasUsed uint64 - BaseFee *big.Int - Difficulty *big.Int - Location common.Location - Time uint64 - Extra []byte - Nonce BlockNonce +// ProtoEncode serializes s into the Quai Proto sealData format +func (h *Header) SealEncode() *ProtoHeader { + uncleHash := common.ProtoHash{Value: h.UncleHash().Bytes()} + root := common.ProtoHash{Value: h.Root().Bytes()} + txHash := common.ProtoHash{Value: h.TxHash().Bytes()} + etxhash := common.ProtoHash{Value: h.EtxHash().Bytes()} + etxRollupHash := common.ProtoHash{Value: h.EtxRollupHash().Bytes()} + receiptHash := common.ProtoHash{Value: h.ReceiptHash().Bytes()} + mixHash := common.ProtoHash{Value: h.MixHash().Bytes()} + gasLimit := h.GasLimit() + gasUsed := h.GasUsed() + time := h.Time() + + protoSealData := &ProtoHeader{ + UncleHash: &uncleHash, + Coinbase: h.Coinbase().Bytes(), + Root: &root, + TxHash: &txHash, + EtxHash: &etxhash, + EtxRollupHash: &etxRollupHash, + ReceiptHash: &receiptHash, + Difficulty: h.Difficulty().Bytes(), + GasLimit: &gasLimit, + GasUsed: &gasUsed, + BaseFee: h.BaseFee().Bytes(), + Location: h.Location().ProtoEncode(), + Time: &time, + Extra: h.Extra(), + MixHash: &mixHash, + } + + for i := 0; i < common.HierarchyDepth; i++ { + protoSealData.ParentHash = append(protoSealData.ParentHash, h.ParentHash(i).ProtoEncode()) + protoSealData.ManifestHash = append(protoSealData.ManifestHash, h.ManifestHash(i).ProtoEncode()) + if h.ParentEntropy(i) != nil { + protoSealData.ParentEntropy = append(protoSealData.ParentEntropy, h.ParentEntropy(i).Bytes()) + } + if h.ParentDeltaS(i) != nil { + protoSealData.ParentDeltaS = append(protoSealData.ParentDeltaS, h.ParentDeltaS(i).Bytes()) + } + if h.Number(i) != nil { + protoSealData.Number = append(protoSealData.Number, h.Number(i).Bytes()) + } + } + return protoSealData } // SealHash returns the hash of a block prior to it being sealed. @@ -629,35 +657,13 @@ func (h *Header) SealHash() (hash common.Hash) { hasherMu.Lock() defer hasherMu.Unlock() hasher.Reset() - hdata := sealData{ - ParentHash: make([]common.Hash, common.HierarchyDepth), - UncleHash: h.UncleHash(), - Coinbase: h.Coinbase(), - Root: h.Root(), - TxHash: h.TxHash(), - EtxHash: h.EtxHash(), - EtxRollupHash: h.EtxRollupHash(), - ManifestHash: make([]common.Hash, common.HierarchyDepth), - ReceiptHash: h.ReceiptHash(), - Number: make([]*big.Int, common.HierarchyDepth), - GasLimit: h.GasLimit(), - GasUsed: h.GasUsed(), - BaseFee: h.BaseFee(), - Difficulty: h.Difficulty(), - Location: h.Location(), - Time: h.Time(), - Extra: h.Extra(), - } - for i := 0; i < common.HierarchyDepth; i++ { - hdata.ParentHash[i] = h.ParentHash(i) - hdata.ManifestHash[i] = h.ManifestHash(i) - hdata.Number[i] = h.Number(i) - } - err := rlp.Encode(hasher, hdata) + protoSealData := h.SealEncode() + data, err := proto.Marshal(protoSealData) if err != nil { - log.Global.Error("Failed to encode header data ", "err", err) + log.Global.Error("Failed to marshal seal data ", "err", err) } - hash.SetBytes(hasher.Sum(hash[:0])) + sum := blake3.Sum256(data[:]) + hash.SetBytes(sum[:]) return hash } diff --git a/core/types/proto_block.pb.go b/core/types/proto_block.pb.go index c27aaae7eb..c19ea58317 100644 --- a/core/types/proto_block.pb.go +++ b/core/types/proto_block.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc-gen-go v1.30.0 +// protoc v4.25.1 // source: core/types/proto_block.proto package types diff --git a/p2p/pb/quai_messages.pb.go b/p2p/pb/quai_messages.pb.go index f80a3baecf..2ecc3beaa1 100644 --- a/p2p/pb/quai_messages.pb.go +++ b/p2p/pb/quai_messages.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc-gen-go v1.30.0 +// protoc v4.25.1 // source: p2p/pb/quai_messages.proto package pb diff --git a/params/config.go b/params/config.go index 6f98abf86c..49bec66ba7 100644 --- a/params/config.go +++ b/params/config.go @@ -26,18 +26,18 @@ import ( // Genesis hashes to enforce below configs on. var ( // Progpow GenesisHashes - ProgpowColosseumGenesisHash = common.HexToHash("0xcdaaf48cc057d97a14acbe76ce5a6e1ab377049059c74416cdfb0c6fd5d0b058") - ProgpowGardenGenesisHash = common.HexToHash("0x7823e58617576af80cc557595380b55c2d565b294e3b6438fc11c4410e48da5e") - ProgpowOrchardGenesisHash = common.HexToHash("0x4042b03aa7c4d6a58d4e6238b2da5c03dda97a0c7e7a7b1d237917a23ca4b0d6") - ProgpowLocalGenesisHash = common.HexToHash("0x53a10194f6b385aa037fe1911b52a56d4d0ac8f95f3e98ac4f546269429c288d") - ProgpowLighthouseGenesisHash = common.HexToHash("0x888542dc6e379e29db4c86934b05cfd4a376e1c19261db3f44d6e4e9f6ce0495") + ProgpowColosseumGenesisHash = common.HexToHash("0xfb82e19862aefe5dd918def4983f95c8033d83362550e868a75ab11ed37a3f9e") + ProgpowGardenGenesisHash = common.HexToHash("0xddceaf0462041712f5ee1c8172727a7ff575fec1a0c8a0e40fc8a4fc852f7d17") + ProgpowOrchardGenesisHash = common.HexToHash("0x05a6769b6fb5050d78b9d8b10d28c401cd22159f30d9825ad04d84f88c253b95") + ProgpowLocalGenesisHash = common.HexToHash("0x20a7d9468e25945c5b8c85d38681ca17ba36bd16a15935ec12b72bd5bae205d6") + ProgpowLighthouseGenesisHash = common.HexToHash("0xcc2411ffdf851780a3ea6d047cb585d5894e9f89d5c396df1a2d125141e36501") // Blake3GenesisHashes - Blake3PowColosseumGenesisHash = common.HexToHash("0x40057f44be0809f939c7d70893d101abc74af1f1c535e406ec9909cfa2c20cbe") - Blake3PowGardenGenesisHash = common.HexToHash("0x0a942bb7fa04b80d658a64d0ca49c62199503a796abc169f05a1863421a22098") - Blake3PowOrchardGenesisHash = common.HexToHash("0x1f3743c323ec7a9a6a8150a33de81723abb70fa10ad49c35e365e48488430b56") - Blake3PowLocalGenesisHash = common.HexToHash("0x31ac78ff6abcd99ad1fd8cd1b8ef54cfb28bdc72f7a38311e67a9e34fc2adb45") - Blake3PowLighthouseGenesisHash = common.HexToHash("0xaadedd7ed5a68a8885b54079e8193ae5be8f9b9bf4799ea9f1612bca835f33da") + Blake3PowColosseumGenesisHash = common.HexToHash("0x1f2980da67d764fcc5034cae36abf54a7c52a64c9202ce69622e38f53a8ad240") + Blake3PowGardenGenesisHash = common.HexToHash("0xa846055f1fad53cc2793f3c6fd7e5d109921b1ea69cf3f1eb091c8933ef3703d") + Blake3PowOrchardGenesisHash = common.HexToHash("0x2607cfd857f2ef4360fb08eb1b49ef2e8b61e65702286f1758cbff7f596924f0") + Blake3PowLocalGenesisHash = common.HexToHash("0x78294bf71dd34f006b9124cda12d843ffbbcab19fbf45aef6e8e2f1a05a5fae3") + Blake3PowLighthouseGenesisHash = common.HexToHash("0x177afb11e5b6ee2fb1fbfa68e601a431ec1194f5abccc548e7236d3a9423e4f5") ) // Different Network names diff --git a/trie/proto_trienode.pb.go b/trie/proto_trienode.pb.go index c306fde3df..aa42437cdd 100644 --- a/trie/proto_trienode.pb.go +++ b/trie/proto_trienode.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 -// protoc v4.25.2 +// protoc-gen-go v1.30.0 +// protoc v4.25.1 // source: trie/proto_trienode.proto package trie