-
Notifications
You must be signed in to change notification settings - Fork 404
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add contract authz proto * Implement contract autorization * Register contract authz * Add contract-authz tests * Consume gas for contract authz * Add contract authz cli * Update cli usage * Model spike * Add max funds limit * Redesign authz model * Start e2e test * Full e2e test * Test filter and limits * Test accept * Fix description * No linter warning Co-authored-by: Giancarlos Salas <me@giansalex.dev>
- Loading branch information
Showing
20 changed files
with
3,790 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
syntax = "proto3"; | ||
package cosmwasm.wasm.v1; | ||
|
||
import "gogoproto/gogo.proto"; | ||
import "cosmos_proto/cosmos.proto"; | ||
import "cosmos/base/v1beta1/coin.proto"; | ||
import "google/protobuf/any.proto"; | ||
|
||
option go_package = "github.com/CosmWasm/wasmd/x/wasm/types"; | ||
option (gogoproto.goproto_getters_all) = false; | ||
|
||
// ContractExecutionAuthorization defines authorization for wasm execute. | ||
// Since: wasmd 0.30 | ||
message ContractExecutionAuthorization { | ||
option (cosmos_proto.implements_interface) = "Authorization"; | ||
|
||
// Grants for contract executions | ||
repeated ContractGrant grants = 1 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// ContractMigrationAuthorization defines authorization for wasm contract | ||
// migration. Since: wasmd 0.30 | ||
message ContractMigrationAuthorization { | ||
option (cosmos_proto.implements_interface) = "Authorization"; | ||
|
||
// Grants for contract migrations | ||
repeated ContractGrant grants = 1 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// ContractGrant a granted permission for a single contract | ||
// Since: wasmd 0.30 | ||
message ContractGrant { | ||
// Contract is the bech32 address of the smart contract | ||
string contract = 1; | ||
|
||
// Limit defines execution limits that are enforced and updated when the grant | ||
// is applied. When the limit lapsed the grant is removed. | ||
google.protobuf.Any limit = 2 | ||
[ (cosmos_proto.accepts_interface) = "ContractAuthzLimitX" ]; | ||
|
||
// Filter define more fine-grained control on the message payload passed | ||
// to the contract in the operation. When no filter applies on execution, the | ||
// operation is prohibited. | ||
google.protobuf.Any filter = 3 | ||
[ (cosmos_proto.accepts_interface) = "ContractAuthzFilterX" ]; | ||
} | ||
|
||
// MaxCallsLimit limited number of calls to the contract. No funds transferable. | ||
// Since: wasmd 0.30 | ||
message MaxCallsLimit { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX"; | ||
|
||
// Remaining number that is decremented on each execution | ||
uint64 remaining = 1; | ||
} | ||
|
||
// MaxFundsLimit defines the maximal amounts that can be sent to the contract. | ||
// Since: wasmd 0.30 | ||
message MaxFundsLimit { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX"; | ||
|
||
// Amounts is the maximal amount of tokens transferable to the contract. | ||
repeated cosmos.base.v1beta1.Coin amounts = 1 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" | ||
]; | ||
} | ||
|
||
// CombinedLimit defines the maximal amounts that can be sent to a contract and | ||
// the maximal number of calls executable. Both need to remain >0 to be valid. | ||
// Since: wasmd 0.30 | ||
message CombinedLimit { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzLimitX"; | ||
|
||
// Remaining number that is decremented on each execution | ||
uint64 calls_remaining = 1; | ||
// Amounts is the maximal amount of tokens transferable to the contract. | ||
repeated cosmos.base.v1beta1.Coin amounts = 2 [ | ||
(gogoproto.nullable) = false, | ||
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" | ||
]; | ||
} | ||
|
||
// AllowAllMessagesFilter is a wildcard to allow any type of contract payload | ||
// message. | ||
// Since: wasmd 0.30 | ||
message AllowAllMessagesFilter { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX"; | ||
} | ||
|
||
// AcceptedMessageKeysFilter accept only the specific contract message keys in | ||
// the json object to be executed. | ||
// Since: wasmd 0.30 | ||
message AcceptedMessageKeysFilter { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX"; | ||
|
||
// Messages is the list of unique keys | ||
repeated string keys = 1; | ||
} | ||
|
||
// AcceptedMessagesFilter accept only the specific raw contract messages to be | ||
// executed. | ||
// Since: wasmd 0.30 | ||
message AcceptedMessagesFilter { | ||
option (cosmos_proto.implements_interface) = "ContractAuthzFilterX"; | ||
|
||
// Messages is the list of raw contract messages | ||
repeated bytes messages = 1 [ (gogoproto.casttype) = "RawContractMessage" ]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# End To End Testing - e2e | ||
|
||
Scenario tests that run against on or multiple chain instances. |
Oops, something went wrong.