-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat(wasm): add contract access control #151
Conversation
3b8b771
to
97d4c0d
Compare
- add an enum `ContractStatus` - add a field `status` into ContractInfo
- add a msg `MsgUpdateContractStatus` - add handler for it
97d4c0d
to
5f2a0ce
Compare
5f2a0ce
to
c6c6868
Compare
Codecov Report
@@ Coverage Diff @@
## v2/develop #151 +/- ##
==============================================
- Coverage 54.99% 53.06% -1.94%
==============================================
Files 812 704 -108
Lines 51487 47274 -4213
==============================================
- Hits 28317 25086 -3231
+ Misses 20211 19629 -582
+ Partials 2959 2559 -400
|
I understood it to be used as Instantiate Auth. However, There is a part that is suspected of being a problem in the planning that the entity with Instantiate authority can instantiate again the Contract that has made the decision to disuse it. However, first of all, we are satisfied with the implementation of the planning prototype based on the address, so we do not care about this in this PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not the status of the contract affect Queries?
@@ -40,3 +45,7 @@ func (p GovAuthorizationPolicy) CanInstantiateContract(types.AccessConfig, sdk.A | |||
func (p GovAuthorizationPolicy) CanModifyContract(sdk.AccAddress, sdk.AccAddress) bool { | |||
return true | |||
} | |||
|
|||
func (p GovAuthorizationPolicy) CanUpdateContractStatus(types.AccessConfig, sdk.AccAddress) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this (and above 3 functions) called and what is this for? Want comment doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added the comment to the code.
@@ -469,7 +472,8 @@ func TestImportContractWithCodeHistoryReset(t *testing.T) { | |||
"code_id": "1", | |||
"creator": "link1p0yx9c9q4xsnedlcn24gqfry5dcu6e9xkhv9aj", | |||
"admin": "link1qyqszqgpqyqszqgpqyqszqgpqyqszqgp8apuk5", | |||
"label": "ȀĴnZV芢毤" | |||
"label": "ȀĴnZV芢毤", | |||
"status": "Active" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mixed Tab vs Space in these templates. Want to unify.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed it to use spaces.
- in function `TestImportContractWithCodeHistoryReset` of `genesis_test.go`
You mean that query responses should not include the status, right? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if contractInfo == nil { | ||
return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "unknown contract") | ||
} | ||
if contractInfo.Status != status { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can status be nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it is a value type.
It can be ContractStatusUnspecified
but it's not a problem.
Description
closes: #126
Add contract status control and execution rejection logic.
Add a permission type
ContractStatusAccess
which defines access control permission.The default value is
NoBody
and it will be modified usinggov
The
ContractStatus
is added inContractInfo
states.And it has two options
Active
andInactive
(Unspecified
option will be rejected)Add a message
MsgUpdateContractStatus
for a qualified permission owner to modify theContractStatus
.If the status
Inactive
, the contract call will be rejected. (Execution, Migration, UpdateAdmin, ClearAdmin)#131 must be merged first
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerCodecov Report
in the comment section below once CI passes