Skip to content

Commit

Permalink
Add maxContractSize parameter and make compileCost parameter adjustable
Browse files Browse the repository at this point in the history
  • Loading branch information
iKapitonau committed Dec 4, 2024
1 parent 4e77cd9 commit b2656c1
Show file tree
Hide file tree
Showing 24 changed files with 1,881 additions and 206 deletions.
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ func (ak *SecretAppKeepers) InitCustomKeepers(
nil,
nil,
&app.LastTxManager,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
ak.ComputeKeeper = &computeKeeper
wasmHooks.ContractKeeper = ak.ComputeKeeper
Expand Down
263 changes: 263 additions & 0 deletions client/docs/swagger-ui/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54577,6 +54577,235 @@ paths:
type: string
tags:
- gRPC Gateway API
/compute/v1beta1/params:
get:
summary: |-
Params defines a gRPC query method that returns the compute
module's parameters.
operationId: ../../tmp-swagger-gen/secret/compute/v1beta1/query.swagger.jsonParams
responses:
'200':
description: A successful response.
schema:
type: object
properties:
params:
description: params defines the parameters of the module.
type: object
properties:
compile_cost:
type: string
description: >-
CompileCost is how much SDK gas we charge *per byte* for
compiling WASM

code.
max_contract_size:
type: string
format: uint64
description: >-
MaxContractSize is the maximum size of contract to store
in bytes.
description: >-
ParamsResponse is the response type for the Query/Params RPC
method.
default:
description: An unexpected error response.
schema:
type: object
properties:
error:
type: string
code:
type: integer
format: int32
message:
type: string
details:
type: array
items:
type: object
properties:
type_url:
type: string
description: >-
A URL/resource name that uniquely identifies the type of
the serialized

protocol buffer message. This string must contain at
least

one "/" character. The last segment of the URL's path
must represent

the fully qualified name of the type (as in

`path/google.protobuf.Duration`). The name should be in
a canonical form

(e.g., leading "." is not accepted).


In practice, teams usually precompile into the binary
all types that they

expect it to use in the context of Any. However, for
URLs which use the

scheme `http`, `https`, or no scheme, one can optionally
set up a type

server that maps type URLs to message definitions as
follows:


* If no scheme is provided, `https` is assumed.

* An HTTP GET on the URL must yield a
[google.protobuf.Type][]
value in binary format, or produce an error.
* Applications are allowed to cache lookup results based
on the
URL, or have them precompiled into a binary to avoid any
lookup. Therefore, binary compatibility needs to be preserved
on changes to types. (Use versioned type names to manage
breaking changes.)

Note: this functionality is not currently available in
the official

protobuf release, and it is not used for type URLs
beginning with

type.googleapis.com.


Schemes other than `http`, `https` (or the empty scheme)
might be

used with implementation specific semantics.
value:
type: string
format: byte
description: >-
Must be a valid serialized protocol buffer of the above
specified type.
description: >-
`Any` contains an arbitrary serialized protocol buffer
message along with a

URL that describes the type of the serialized message.


Protobuf library provides support to pack/unpack Any values
in the form

of utility functions or additional generated methods of the
Any type.


Example 1: Pack and unpack a message in C++.

Foo foo = ...;
Any any;
any.PackFrom(foo);
...
if (any.UnpackTo(&foo)) {
...
}

Example 2: Pack and unpack a message in Java.

Foo foo = ...;
Any any = Any.pack(foo);
...
if (any.is(Foo.class)) {
foo = any.unpack(Foo.class);
}
// or ...
if (any.isSameTypeAs(Foo.getDefaultInstance())) {
foo = any.unpack(Foo.getDefaultInstance());
}

Example 3: Pack and unpack a message in Python.

foo = Foo(...)
any = Any()
any.Pack(foo)
...
if any.Is(Foo.DESCRIPTOR):
any.Unpack(foo)
...

Example 4: Pack and unpack a message in Go

foo := &pb.Foo{...}
any, err := anypb.New(foo)
if err != nil {
...
}
...
foo := &pb.Foo{}
if err := any.UnmarshalTo(foo); err != nil {
...
}

The pack methods provided by protobuf library will by
default use

'type.googleapis.com/full.type.name' as the type URL and the
unpack

methods only use the fully qualified type name after the
last '/'

in the type URL, for example "foo.bar.com/x/y.z" will yield
type

name "y.z".


JSON

====

The JSON representation of an `Any` value uses the regular

representation of the deserialized, embedded message, with
an

additional field `@type` which contains the type URL.
Example:

package google.profile;
message Person {
string first_name = 1;
string last_name = 2;
}

{
"@type": "type.googleapis.com/google.profile.Person",
"firstName": <string>,
"lastName": <string>
}

If the embedded message type is well-known and has a custom
JSON

representation, that representation will be embedded adding
a field

`value` which holds the custom JSON in addition to the
`@type`

field. Example (for message [google.protobuf.Duration][]):

{
"@type": "type.googleapis.com/google.protobuf.Duration",
"value": "1.212s"
}
tags:
- gRPC Gateway API
/compute/v1beta1/query/{contract_address}:
get:
summary: Query secret contract
Expand Down Expand Up @@ -98751,6 +98980,40 @@ definitions:
title: |-
ContractInfoWithAddress adds the contract address to the ContractInfo
representation
secret.compute.v1beta1.Params:
type: object
properties:
compile_cost:
type: string
description: >-
CompileCost is how much SDK gas we charge *per byte* for compiling
WASM

code.
max_contract_size:
type: string
format: uint64
description: MaxContractSize is the maximum size of contract to store in bytes.
description: Params defines the parameters for the compute module.
secret.compute.v1beta1.ParamsResponse:
type: object
properties:
params:
description: params defines the parameters of the module.
type: object
properties:
compile_cost:
type: string
description: >-
CompileCost is how much SDK gas we charge *per byte* for compiling
WASM

code.
max_contract_size:
type: string
format: uint64
description: MaxContractSize is the maximum size of contract to store in bytes.
description: ParamsResponse is the response type for the Query/Params RPC method.
secret.compute.v1beta1.QueryCodeHashResponse:
type: object
properties:
Expand Down
4 changes: 3 additions & 1 deletion proto/secret/compute/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package secret.compute.v1beta1;

import "gogoproto/gogo.proto";
import "secret/compute/v1beta1/params.proto";
import "secret/compute/v1beta1/types.proto";

option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types";
Expand All @@ -19,6 +20,7 @@ message GenesisState {
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "sequences,omitempty"
];
Params params = 5 [ (gogoproto.nullable) = false ];
}

// Code struct encompasses CodeInfo and CodeBytes
Expand All @@ -42,4 +44,4 @@ message Contract {
message Sequence {
bytes id_key = 1 [ (gogoproto.customname) = "IDKey" ];
uint64 value = 2;
}
}
21 changes: 21 additions & 0 deletions proto/secret/compute/v1beta1/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types"

import "gogoproto/gogo.proto";
import "cosmos/msg/v1/msg.proto";
import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "amino/amino.proto";
import "secret/compute/v1beta1/params.proto";

// Msg defines the wasm Msg service.
service Msg {
Expand All @@ -24,6 +26,8 @@ service Msg {
rpc UpdateAdmin(MsgUpdateAdmin) returns (MsgUpdateAdminResponse);
// ClearAdmin removes any admin stored for a smart contract
rpc ClearAdmin(MsgClearAdmin) returns (MsgClearAdminResponse);
// UpdateParams updates compute module params
rpc UpdateParams(MsgUpdateParams) returns (MsgUpdateParamsResponse);
}

message MsgStoreCode {
Expand Down Expand Up @@ -179,3 +183,20 @@ message MsgClearAdmin {

// MsgClearAdminResponse returns empty data
message MsgClearAdminResponse {}

// MsgUpdateParams updates params of compute module
message MsgUpdateParams {
option (cosmos.msg.v1.signer) = "authority";
option (amino.name) = "wasm/MsgUpdateParams";

// authority is the address of the governance account.
string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// params defines the x/compute parameters to update.
//
// NOTE: All parameters must be supplied.
Params params = 2 [ (gogoproto.nullable) = false ];
}

// MsgClearAdminResponse returns empty data
message MsgUpdateParamsResponse {}
22 changes: 22 additions & 0 deletions proto/secret/compute/v1beta1/params.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
syntax = "proto3";
package secret.compute.v1beta1;

import "gogoproto/gogo.proto";
import "cosmos_proto/cosmos.proto";
import "amino/amino.proto";

option go_package = "github.com/scrtlabs/SecretNetwork/x/compute/internal/types";

// Params defines the parameters for the compute module.
message Params {
// CompileCost is how much SDK gas we charge *per byte* for compiling WASM
// code.
string compile_cost = 1 [
(cosmos_proto.scalar) = "cosmos.Dec",
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false,
(amino.dont_omitempty) = true
];
// MaxContractSize is the maximum size of contract to store in bytes.
uint64 max_contract_size = 2 [ (amino.dont_omitempty) = true ];
}
Loading

0 comments on commit b2656c1

Please sign in to comment.