Skip to content

Commit

Permalink
Tmp Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
evgeniy-scherbina committed May 8, 2024
1 parent b38c516 commit 71b47ab
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions x/evm/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,21 @@ func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams)

ctx := sdk.UnwrapSDKContext(goCtx)

if err := k.updatePrecompiles(ctx, req.Params.EnabledPrecompiles); err != nil {
return nil, err
}

if err := k.SetParams(ctx, req.Params); err != nil {
return nil, err
}

return &types.MsgUpdateParamsResponse{}, nil
}

func (k *Keeper) updatePrecompiles(ctx sdk.Context, newEnabledPrecompiles []string) error {
oldParams := k.GetParams(ctx)
oldEnabledPrecompiles := oldParams.GetEnabledPrecompiles()

newEnabledPrecompiles := req.Params.EnabledPrecompiles
newEnabledPrecompilesMap := make(map[common.Address]struct{}, len(newEnabledPrecompiles))

for _, hexAddr := range newEnabledPrecompiles {
Expand All @@ -179,7 +190,7 @@ func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams)
CodeHash: codeHash[:],
})
if err != nil {
return nil, err
return err
}

// Set the code of the precompile's address to a non-zero length byte slice to ensure that the precompile
Expand All @@ -195,13 +206,9 @@ func (k *Keeper) UpdateParams(goCtx context.Context, req *types.MsgUpdateParams)
}

if err := k.DeleteAccount(ctx, addr); err != nil {
return nil, err
return err
}
}

if err := k.SetParams(ctx, req.Params); err != nil {
return nil, err
}

return &types.MsgUpdateParamsResponse{}, nil
return nil
}

0 comments on commit 71b47ab

Please sign in to comment.