From c5dbc4415faf4be1562b340040181125ddeb8343 Mon Sep 17 00:00:00 2001 From: gop Date: Thu, 31 Aug 2023 17:32:17 -0500 Subject: [PATCH] Revert "Added primeTermini array to Termini struct with helpers" This reverts commit b8f3921e5390fdd0b655daada43a7017bde9253d. --- core/types/block.go | 57 ++++++----------------------------- core/types/gen_header_json.go | 17 +++-------- 2 files changed, 14 insertions(+), 60 deletions(-) diff --git a/core/types/block.go b/core/types/block.go index 74913e710b..822d612f48 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -1020,9 +1020,8 @@ type extPendingHeader struct { func (t Termini) RPCMarshalTermini() map[string]interface{} { result := map[string]interface{}{ - "domTerminus": t.DomTerminus(), - "subTermini": t.SubTermini(), - "primeTermini": t.PrimeTermini(), + "domTerminus": t.DomTerminus(), + "subTermini": t.SubTermini(), } return result } @@ -1047,13 +1046,9 @@ func (p PendingHeader) EncodeRLP(w io.Writer) error { // Termini stores the dom terminus (i.e the previous dom block) and // subTermini(i.e the dom blocks that have occured in the subordinate chains) -// primeTermini(i.e the prime blocks have occured in a region for each of the zones in region) -// - prime termini is used to control the liveliness of the primes in slices -// using the PrimeEntropyThreshold type Termini struct { - domTerminus common.Hash `json:"domTerminus"` - subTermini []common.Hash `json:"subTermini"` - primeTermini []common.Hash `json:"primeTermini"` + domTerminus common.Hash `json:"domTerminus"` + subTermini []common.Hash `json:"subTermini"` } func CopyTermini(termini Termini) Termini { @@ -1062,16 +1057,12 @@ func CopyTermini(termini Termini) Termini { for i, t := range termini.subTermini { newTermini.SetSubTerminiAtIndex(t, i) } - for i, t := range termini.primeTermini { - newTermini.SetPrimeTerminiAtIndex(t, i) - } return newTermini } func EmptyTermini() Termini { termini := Termini{} termini.subTermini = make([]common.Hash, common.HierarchyDepth) - termini.primeTermini = make([]common.Hash, common.NumZonesInRegion) return termini } @@ -1083,10 +1074,6 @@ func (t Termini) SubTermini() []common.Hash { return t.subTermini } -func (t Termini) PrimeTermini() []common.Hash { - return t.primeTermini -} - func (t Termini) SubTerminiAtIndex(args ...int) common.Hash { if len(args) == 0 { panic("cannot access sub termini at index with the index") @@ -1094,13 +1081,6 @@ func (t Termini) SubTerminiAtIndex(args ...int) common.Hash { return t.subTermini[args[0]] } -func (t Termini) PrimeTerminiAtIndex(args ...int) common.Hash { - if len(args) == 0 { - panic("cannot access prime termini at index with the index") - } - return t.primeTermini[args[0]] -} - func (t *Termini) SetDomTerminus(domTerminus common.Hash) { t.domTerminus = domTerminus } @@ -1112,13 +1092,6 @@ func (t *Termini) SetSubTermini(subTermini []common.Hash) { } } -func (t *Termini) SetPrimeTermini(primeTermini []common.Hash) { - t.primeTermini = make([]common.Hash, len(primeTermini)) - for i := 0; i < len(primeTermini); i++ { - t.primeTermini[i] = primeTermini[i] - } -} - func (t *Termini) SetSubTerminiAtIndex(val common.Hash, args ...int) { if len(args) == 0 { panic("index cannot be empty for the sub termini") @@ -1126,13 +1099,6 @@ func (t *Termini) SetSubTerminiAtIndex(val common.Hash, args ...int) { t.subTermini[args[0]] = val } -func (t *Termini) SetPrimeTerminiAtIndex(val common.Hash, args ...int) { - if len(args) == 0 { - panic("index cannot be empty for the prime termini") - } - t.primeTermini[args[0]] = val -} - func (t *Termini) IsValid() bool { if t == nil { return false @@ -1140,17 +1106,13 @@ func (t *Termini) IsValid() bool { if len(t.subTermini) != common.HierarchyDepth { return false } - if len(t.primeTermini) != common.NumZonesInRegion { - return false - } return true } // "external termini" pending header encoding. used for rlp type extTermini struct { - DomTerminus common.Hash - SubTermini []common.Hash - PrimeTermini []common.Hash + DomTerminus common.Hash + SubTermini []common.Hash } // DecodeRLP decodes the Quai RLP encoding into pending header format. @@ -1159,16 +1121,15 @@ func (t *Termini) DecodeRLP(s *rlp.Stream) error { if err := s.Decode(&et); err != nil { return err } - t.domTerminus, t.subTermini, t.primeTermini = et.DomTerminus, et.SubTermini, et.PrimeTermini + t.domTerminus, t.subTermini = et.DomTerminus, et.SubTermini return nil } // EncodeRLP serializes b into the Quai RLP format. func (t Termini) EncodeRLP(w io.Writer) error { return rlp.Encode(w, extTermini{ - DomTerminus: t.domTerminus, - SubTermini: t.subTermini, - PrimeTermini: t.primeTermini, + DomTerminus: t.domTerminus, + SubTermini: t.subTermini, }) } diff --git a/core/types/gen_header_json.go b/core/types/gen_header_json.go index 0b635ea93d..8dbf5c63d2 100644 --- a/core/types/gen_header_json.go +++ b/core/types/gen_header_json.go @@ -201,12 +201,10 @@ func (h *Header) UnmarshalJSON(input []byte) error { func (t Termini) MarshalJSON() ([]byte, error) { var enc struct { - DomTermius common.Hash `json:"domTerminus" gencodec:"required"` - SubTermini []common.Hash `json:"subTermini" gencodec:"required"` - PrimeTermini []common.Hash `json:"primeTermini" gencodec:"required"` + DomTermius common.Hash `json:"domTerminus" gencodec:"required"` + SubTermini []common.Hash `json:"subTermini" gencodec:"required"` } copy(enc.SubTermini, t.SubTermini()) - copy(enc.PrimeTermini, t.PrimeTermini()) enc.DomTermius = t.DomTerminus() raw, err := json.Marshal(&enc) return raw, err @@ -214,9 +212,8 @@ func (t Termini) MarshalJSON() ([]byte, error) { func (t *Termini) UnmarshalJSON(input []byte) error { var dec struct { - DomTermius *common.Hash `json:"domTerminus" gencodec:"required"` - SubTermini []common.Hash `json:"subTermini" gencodec:"required"` - PrimeTermini []common.Hash `json:"primeTermini" gencodec:"required"` + DomTermius *common.Hash `json:"domTerminus" gencodec:"required"` + SubTermini []common.Hash `json:"subTermini" gencodec:"required"` } if err := json.Unmarshal(input, &dec); err != nil { return err @@ -224,14 +221,10 @@ func (t *Termini) UnmarshalJSON(input []byte) error { if dec.DomTermius == nil { return errors.New("missing required field 'domTerminus' for Termini") } - if dec.SubTermini == nil { + if dec.SubTermini== nil { return errors.New("missing required field 'subTermini' for Termini") } - if dec.PrimeTermini == nil { - return errors.New("missing require field 'primeTermini' for Termini") - } t.SetDomTerminus(*dec.DomTermius) t.SetSubTermini(dec.SubTermini) - t.SetPrimeTermini(dec.PrimeTermini) return nil }