Skip to content

Commit

Permalink
upgrade proposal ante handler fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad committed Oct 30, 2024
1 parent 104bb9f commit d623cc2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions x/compute/internal/keeper/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (a CountTXDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool,
if ok {
err = a.verifyUpgradeProposal(ctx, msgUpgrade)
if err != nil {
fmt.Println("*** upgrade proposal pass rejected: ", err)
return ctx, err
}
}
Expand Down Expand Up @@ -141,17 +142,22 @@ func (a *CountTXDecorator) verifyUpgradeProposal(ctx sdk.Context, msgUpgrade *ty
}
}

if latestProposal == nil {
return fmt.Errorf("no latest upgrade proposal")
}

// If we found the MsgSoftwareUpgrade latest passed proposal, extract the MREnclaveHash from it
if latestProposal != nil {
info, err := extractInfoFromProposalMessages(latestProposal.Messages[0], a.appcodec)
if err != nil {
return fmt.Errorf("Failed to extract info with MREnclave hash from Proposal, error: %w", err)
}
latestMREnclaveHash, _ = findMREnclaveHash(info)
info, err := extractInfoFromProposalMessages(latestProposal.Messages[0], a.appcodec)
if err != nil {
return fmt.Errorf("Failed to extract info with MREnclave hash from Proposal, error: %w", err)

Check failure on line 152 in x/compute/internal/keeper/ante.go

View workflow job for this annotation

GitHub Actions / lint

ST1005: error strings should not be capitalized (stylecheck)
}
latestMREnclaveHash, _ = findMREnclaveHash(info)
if latestMREnclaveHash == nil {
return fmt.Errorf("no mrenclave in the latest upgrade proposal")
}

// Check if the MREnclave hash matches the one in the MsgUpgradeProposalPassed message
if (latestMREnclaveHash != nil) && bytes.Equal(latestMREnclaveHash, msgUpgrade.MrEnclaveHash) {
if !bytes.Equal(latestMREnclaveHash, msgUpgrade.MrEnclaveHash) {
return sdkerrors.ErrUnauthorized.Wrap("software upgrade proposal: mrenclave hash mismatch")
}
return nil
Expand Down

0 comments on commit d623cc2

Please sign in to comment.