Skip to content

Commit

Permalink
Merge pull request #3206 from oasisprotocol/kostko/fix/commit-pool-pa…
Browse files Browse the repository at this point in the history
…rent-check

go/roothash: Make the parent block check earlier
  • Loading branch information
kostko authored Aug 21, 2020
2 parents 89225d6 + f4679db commit 767c163
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
1 change: 1 addition & 0 deletions .changelog/3206.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go/roothash: Make the parent block check earlier
22 changes: 10 additions & 12 deletions go/roothash/api/commitment/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,6 @@ func (p *Pool) addOpenExecutorCommitment(
return ErrNotInCommittee
}

// TODO: Check for signs of double signing (#1804).

// Ensure the node did not already submit a commitment.
if _, ok := p.ExecuteCommitments[id]; ok {
return ErrAlreadyCommitted
Expand All @@ -169,6 +167,16 @@ func (p *Pool) addOpenExecutorCommitment(
return ErrInvalidMessages
}

// Check if the block is based on the previous block.
if !header.IsParentOf(&blk.Header) {
logger.Debug("executor commitment is not based on correct block",
"node_id", id,
"expected_previous_hash", blk.Header.EncodedHash(),
"previous_hash", header.PreviousHash,
)
return ErrNotBasedOnCorrectBlock
}

// Verify RAK-attestation.
if p.Runtime.TEEHardware != node.TEEHardwareInvalid {
n, err := nl.Node(ctx, id)
Expand Down Expand Up @@ -198,16 +206,6 @@ func (p *Pool) addOpenExecutorCommitment(
}
}

// Check if the block is based on the previous block.
if !header.IsParentOf(&blk.Header) {
logger.Debug("executor commitment is not based on correct block",
"node_id", id,
"expected_previous_hash", blk.Header.EncodedHash(),
"previous_hash", header.PreviousHash,
)
return ErrNotBasedOnCorrectBlock
}

if err := sv.VerifyTxnSchedulerSignature(body.TxnSchedSig, blk.Header.Round); err != nil {
logger.Debug("executor commitment has bad transaction scheduler signer",
"node_id", id,
Expand Down

0 comments on commit 767c163

Please sign in to comment.