Skip to content

Commit

Permalink
Remove RunAs from Migrate proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Jan 24, 2022
1 parent 82f023c commit 0a96e26
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 129 deletions.
9 changes: 5 additions & 4 deletions docs/proto/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ contract.
| `description` | [string](#string) | | Description is a human readable text |
| `run_as` | [string](#string) | | RunAs is the address that is passed to the contract's environment as sender |
| `contract` | [string](#string) | | Contract is the address of the smart contract |
| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract as sudo |
| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract as execute |



Expand Down Expand Up @@ -712,10 +712,11 @@ MigrateContractProposal gov proposal content type to migrate a contract.
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `title` | [string](#string) | | Title is a short summary |
| `description` | [string](#string) | | Description is a human readable text |
| `run_as` | [string](#string) | | FIXME: I think this is unused? Migrate has no sender RunAs is the address that is passed to the contract's environment as sender |
| `description` | [string](#string) | | Description is a human readable text

Note: skipping 3 as this was previously used for unneeded run_as |
| `contract` | [string](#string) | | Contract is the address of the smart contract |
| `code_id` | [uint64](#uint64) | | CodeID references the new WASM code |
| `code_id` | [uint64](#uint64) | | CodeID references the new WASM codesudo |
| `msg` | [bytes](#bytes) | | Msg json encoded message to be passed to the contract on migration |


Expand Down
9 changes: 4 additions & 5 deletions proto/cosmwasm/wasm/v1/proposal.proto
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ message MigrateContractProposal {
string title = 1;
// Description is a human readable text
string description = 2;
// FIXME: I think this is unused? Migrate has no sender
// RunAs is the address that is passed to the contract's environment as sender
string run_as = 3;
// Note: skipping 3 as this was previously used for unneeded run_as

// Contract is the address of the smart contract
string contract = 4;
// CodeID references the new WASM code
// CodeID references the new WASM codesudo
uint64 code_id = 5 [ (gogoproto.customname) = "CodeID" ];
// Msg json encoded message to be passed to the contract on migration
bytes msg = 6 [ (gogoproto.casttype) = "RawContractMessage" ];
Expand Down Expand Up @@ -90,7 +89,7 @@ message ExecuteContractProposal {
string run_as = 3;
// Contract is the address of the smart contract
string contract = 4;
// Msg json encoded message to be passed to the contract as sudo
// Msg json encoded message to be passed to the contract as execute
bytes msg = 5 [ (gogoproto.casttype) = "RawContractMessage" ];
}

Expand Down
9 changes: 0 additions & 9 deletions x/wasm/client/cli/gov_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,6 @@ func ProposalMigrateContractCmd() *cobra.Command {
return err
}

runAs, err := cmd.Flags().GetString(flagRunAs)
if err != nil {
return fmt.Errorf("run-as: %s", err)
}
if len(runAs) == 0 {
return errors.New("run-as address is required")
}
proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle)
if err != nil {
return fmt.Errorf("proposal title: %s", err)
Expand All @@ -211,7 +204,6 @@ func ProposalMigrateContractCmd() *cobra.Command {
Contract: src.Contract,
CodeID: src.CodeID,
Msg: src.Msg,
RunAs: runAs,
}

msg, err := govtypes.NewMsgSubmitProposal(&content, deposit, clientCtx.GetFromAddress())
Expand All @@ -225,7 +217,6 @@ func ProposalMigrateContractCmd() *cobra.Command {
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}
cmd.Flags().String(flagRunAs, "", "The address that is passed as sender to the contract on proposal execution")

// proposal flags
cmd.Flags().String(cli.FlagTitle, "", "Title of proposal")
Expand Down
3 changes: 0 additions & 3 deletions x/wasm/client/rest/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ type MigrateProposalJSONReq struct {
Contract string `json:"contract" yaml:"contract"`
Code uint64 `json:"code_id" yaml:"code_id"`
Msg json.RawMessage `json:"msg" yaml:"msg"`
// RunAs is the role that is passed to the contract's environment
RunAs string `json:"run_as" yaml:"run_as"`
}

func (s MigrateProposalJSONReq) Content() govtypes.Content {
Expand All @@ -137,7 +135,6 @@ func (s MigrateProposalJSONReq) Content() govtypes.Content {
Contract: s.Contract,
CodeID: s.Code,
Msg: types.RawContractMessage(s.Msg),
RunAs: s.RunAs,
}
}
func (s MigrateProposalJSONReq) GetProposer() string {
Expand Down
4 changes: 2 additions & 2 deletions x/wasm/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ func handleMigrateProposal(ctx sdk.Context, k types.ContractOpsKeeper, p types.M
if err != nil {
return sdkerrors.Wrap(err, "contract")
}
runAsAddr, err := sdk.AccAddressFromBech32(p.RunAs)
if err != nil {
return sdkerrors.Wrap(err, "run as address")
}
data, err := k.Migrate(ctx, contractAddr, runAsAddr, p.CodeID, p.Msg)
// runAs is not used if this is permissioned, so just put any valid address there (second contractAddr)
data, err := k.Migrate(ctx, contractAddr, contractAddr, p.CodeID, p.Msg)
if err != nil {
return err
}
Expand Down
8 changes: 1 addition & 7 deletions x/wasm/types/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ func (p MigrateContractProposal) ValidateBasic() error {
if _, err := sdk.AccAddressFromBech32(p.Contract); err != nil {
return sdkerrors.Wrap(err, "contract")
}
if _, err := sdk.AccAddressFromBech32(p.RunAs); err != nil {
return sdkerrors.Wrap(err, "run as")
}
if err := p.Msg.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "payload msg")
}
Expand All @@ -261,9 +258,8 @@ func (p MigrateContractProposal) String() string {
Description: %s
Contract: %s
Code id: %d
Run as: %s
Msg %q
`, p.Title, p.Description, p.Contract, p.CodeID, p.RunAs, p.Msg)
`, p.Title, p.Description, p.Contract, p.CodeID, p.Msg)
}

// MarshalYAML pretty prints the migrate message
Expand All @@ -274,14 +270,12 @@ func (p MigrateContractProposal) MarshalYAML() (interface{}, error) {
Contract string `yaml:"contract"`
CodeID uint64 `yaml:"code_id"`
Msg string `yaml:"msg"`
RunAs string `yaml:"run_as"`
}{
Title: p.Title,
Description: p.Description,
Contract: p.Contract,
CodeID: p.CodeID,
Msg: string(p.Msg),
RunAs: p.RunAs,
}, nil
}

Expand Down
148 changes: 50 additions & 98 deletions x/wasm/types/proposal.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion x/wasm/types/test_fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,6 @@ func MigrateContractProposalFixture(mutators ...func(p *MigrateContractProposal)
Contract: contractAddr,
CodeID: 1,
Msg: migMsgBz,
RunAs: anyAddress,
}

for _, m := range mutators {
Expand Down

0 comments on commit 0a96e26

Please sign in to comment.