Skip to content

Commit

Permalink
Merge pull request dominant-strategies#345 from spruce-solutions/reve…
Browse files Browse the repository at this point in the history
…rt-reorg-twist

core/blockchain.go: reverted the reorgTwistToCommonAncestor
  • Loading branch information
shreekarashastry authored Jul 7, 2022
2 parents a153714 + 95972e9 commit 6d8112f
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -3120,7 +3120,7 @@ func (bc *BlockChain) PCRC(header *types.Header) (common.Hash, error) {
// 2. If Zone terminus is in our chain, do nothing.
// 3. If Zone terminus is not in our chain, uncle the RTZ in the subordinate context.
if types.QuaiNetworkContext <= params.REGION {
err = bc.reorgTwistToCommonAncestor(RTZ, RTR, slice, params.REGION, params.ZONE)
err = bc.reorgTwistToCommonAncestor(RTZ, slice, params.REGION, params.ZONE)
if err != nil {
return common.Hash{}, errors.New("unable to reorg to common ancestor after region twist")
}
Expand Down Expand Up @@ -3155,7 +3155,7 @@ func (bc *BlockChain) PCRC(header *types.Header) (common.Hash, error) {
if PTR.Hash() != PTP.Hash() {
log.Info("Error in PCRC", "PTR:", PTR.Hash(), "RTR:", PTP.Hash())
if types.QuaiNetworkContext == params.PRIME {
err = bc.reorgTwistToCommonAncestor(PTR, PTP, slice, params.PRIME, params.REGION)
err = bc.reorgTwistToCommonAncestor(PTR, slice, params.PRIME, params.REGION)
if err != nil {
return common.Hash{}, errors.New("unable to reorg to common ancestor after prime (PTP) twist")
}
Expand All @@ -3166,7 +3166,7 @@ func (bc *BlockChain) PCRC(header *types.Header) (common.Hash, error) {
if PTZ.Hash() != PTR.Hash() {
log.Info("Error in PCRC", "PTZ:", PTZ.Hash(), "PTR:", PTR.Hash())
if types.QuaiNetworkContext == params.PRIME {
err = bc.reorgTwistToCommonAncestor(PTZ, PTR, slice, params.PRIME, params.ZONE)
err = bc.reorgTwistToCommonAncestor(PTZ, slice, params.PRIME, params.ZONE)
if err != nil {
return common.Hash{}, errors.New("unable to reorg to common ancestor after prime (PTR) twist")
}
Expand All @@ -3183,7 +3183,7 @@ func (bc *BlockChain) PCRC(header *types.Header) (common.Hash, error) {
// This uncle will rollback the subordinate chain in the manager process.
// If there are many invalid subordinate heads, aggregate the valid subordinate blocks (NewSubs) off of the valid dominant chain (RTR / PTP / PTR)
// and include them for processing in the manager.
func (bc *BlockChain) reorgTwistToCommonAncestor(subHead *types.Header, domHead *types.Header, slice []byte, order int, path int) error {
func (bc *BlockChain) reorgTwistToCommonAncestor(subHead *types.Header, slice []byte, order int, path int) error {
num := bc.hc.GetBlockNumber(subHead.Hash())

if num != nil {
Expand All @@ -3201,13 +3201,8 @@ func (bc *BlockChain) reorgTwistToCommonAncestor(subHead *types.Header, domHead
num = bc.hc.GetBlockNumber(prevHeader.Hash())

if num != nil {
// get all the external blocks on the subordinate chain path until common point
extBlocks, err := bc.GetExternalBlockTraceSet(prevHeader.Hash(), domHead, path)
if err != nil {
return err
}
// Remove non-cononical blocks from subordinate chains.
bc.reOrgFeed.Send(ReOrgRollup{ReOrgHeader: prev, OldChainHeaders: []*types.Header{prev}, NewChainHeaders: []*types.Header{domHead}, NewSubs: extBlocks})
bc.chainUncleFeed.Send(prev)
return nil
}
prev = prevHeader
Expand Down

0 comments on commit 6d8112f

Please sign in to comment.