Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: MRENCLAVE support antehandler #1676

Open
wants to merge 3 commits into
base: cosmos-sdk-0.50.x-merged
Choose a base branch
from

Conversation

cboh4
Copy link

@cboh4 cboh4 commented Sep 10, 2024

No description provided.

Now MREnclaveHash resides in the "Plan.info" field of the MsgSoftwareUpgrade message. We find the latest passed proposal and extract MREnclaveHash from there.
// verifyUpgradeProposal verifies the latest passed upgrade proposal to ensure the MREnclave hash matches.
func (a *CountTXDecorator) verifyUpgradeProposal(ctx sdk.Context, msgUpgrade *types.MsgUpgradeProposalPassed) error {
iterator, err := a.govkeeper.Proposals.Iterate(ctx, nil)
if err != nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.Logger().Error(fmt.Sprintf("Governance Keeper Proposal: %s", err))
No need to use ! sign.

func (a *CountTXDecorator) verifyUpgradeProposal(ctx sdk.Context, msgUpgrade *types.MsgUpgradeProposalPassed) error {
iterator, err := a.govkeeper.Proposals.Iterate(ctx, nil)
if err != nil {
ctx.Logger().Error("Failed to get the iterator of proposals!", err.Error())
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to return the actual error

var latestMREnclaveHash string

// Iterate through the proposals
for ; iterator.Valid(); iterator.Next() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should use for range iterator construct

proposal, err := iterator.Value()
if err != nil {
ctx.Logger().Error("Failed to get the proposal from iterator!", err.Error())
return errors.New("Failed to get the proposal from iterator!")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

user fmt.Errorf. No need to use ! sign

}
// Check if the proposal has passed and is of type MsgSoftwareUpgrade
if proposal.Status == v1.ProposalStatus_PROPOSAL_STATUS_PASSED {
if len(proposal.GetMessages()) > 0 && proposal.Messages[0].GetTypeUrl() == "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade" {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a const for "/cosmos.upgrade.v1beta1.MsgSoftwareUpgrade"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants