Skip to content

Commit

Permalink
Allow sibling inclusion for workshares
Browse files Browse the repository at this point in the history
  • Loading branch information
gameofpointers committed Jun 7, 2024
1 parent a565777 commit 03d45b4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
11 changes: 9 additions & 2 deletions consensus/blake3pow/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,19 @@ func (blake3pow *Blake3pow) VerifyUncles(chain consensus.ChainReader, block *typ
if ancestors[hash] != nil {
return errUncleIsAncestor
}
if ancestors[uncle.ParentHash()] == nil || uncle.ParentHash() == block.ParentHash(nodeCtx) {
// Siblings are not allowed to be included in the workshares list if its an
// uncle but can be if its a workshare
var workShare bool
_, err := blake3pow.VerifySeal(uncle)
if err != nil {
workShare = true
}
if ancestors[uncle.ParentHash()] == nil || (!workShare && (uncle.ParentHash() == block.ParentHash(nodeCtx))) {
return errDanglingUncle
}

// make sure that the work can be computed
_, err := blake3pow.ComputePowHash(uncle)
_, err = blake3pow.ComputePowHash(uncle)
if err != nil {
return err
}
Expand Down
11 changes: 9 additions & 2 deletions consensus/progpow/consensus.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,17 @@ func (progpow *Progpow) VerifyUncles(chain consensus.ChainReader, block *types.W
if ancestors[hash] != nil {
return errUncleIsAncestor
}
if ancestors[uncle.ParentHash()] == nil || uncle.ParentHash() == block.ParentHash(nodeCtx) {
// Siblings are not allowed to be included in the workshares list if its an
// uncle but can be if its a workshare
var workShare bool
_, err := progpow.VerifySeal(uncle)
if err != nil {
workShare = true
}
if ancestors[uncle.ParentHash()] == nil || (!workShare && (uncle.ParentHash() == block.ParentHash(nodeCtx))) {
return errDanglingUncle
}
_, err := progpow.ComputePowHash(uncle)
_, err = progpow.ComputePowHash(uncle)
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion core/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,13 @@ func (w *worker) commitUncle(env *environment, uncle *types.WorkObjectHeader) er
if _, exist := env.uncles[hash]; exist {
return errors.New("uncle not unique")
}
if env.wo.ParentHash(w.hc.NodeCtx()) == uncle.ParentHash() {
var workShare bool
// If the uncle is a workshare, we should allow siblings
_, err := w.engine.VerifySeal(uncle)
if err != nil {
workShare = true
}
if !workShare && (env.wo.ParentHash(w.hc.NodeCtx()) == uncle.ParentHash()) {
return errors.New("uncle is sibling")
}
if !env.ancestors.Contains(uncle.ParentHash()) {
Expand Down

0 comments on commit 03d45b4

Please sign in to comment.