Skip to content

Draft: MRENCLAVE support antehandler #1676

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

Merged

Conversation

cboh4
Copy link
Contributor

@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
Contributor

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
Contributor

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
Contributor

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
Contributor

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
Contributor

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"

@cboh4 cboh4 requested review from quaisx and iKapitonau September 18, 2024 07:48
@iKapitonau iKapitonau force-pushed the cosmos-sdk-0.50.x-merged branch from 1857d07 to a95b51a Compare September 26, 2024 12:12
@iKapitonau iKapitonau force-pushed the cosmos-sdk-0.50.x-merged branch from 8f32ac2 to 405cbc0 Compare October 11, 2024 09:08
@valdok valdok merged commit 3cf353d into cosmos-sdk-0.50.x-merged Oct 28, 2024
9 of 10 checks passed
@valdok valdok deleted the chb19/cosmod-sdk-0.50.x-antehandler-mrenclave branch October 28, 2024 15:44
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.

3 participants