Skip to content

Commit

Permalink
ictx + transfer with limited sudo call
Browse files Browse the repository at this point in the history
  • Loading branch information
swelf19 committed Aug 17, 2023
1 parent bbd7b39 commit 509e332
Show file tree
Hide file tree
Showing 25 changed files with 358 additions and 248 deletions.
10 changes: 10 additions & 0 deletions app/upgrades/sdk47/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
v6 "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/controller/migrations/v6"
"github.com/neutron-org/neutron/app/upgrades"
contractmanagermoduletypes "github.com/neutron-org/neutron/x/contractmanager/types"
crontypes "github.com/neutron-org/neutron/x/cron/types"
feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types"
feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types"
Expand Down Expand Up @@ -91,6 +92,15 @@ func CreateUpgradeHandler(
return nil, err
}

ctx.Logger().Info("Setting sudo callback limit...")
cmParams := contractmanagermoduletypes.Params{
SudoCallGasLimit: 1_000_000,
}
err = keepers.ContractManager.SetParams(ctx, cmParams)
if err != nil {
return nil, err
}

ctx.Logger().Info("Upgrade complete")
return vm, nil
}
Expand Down
2 changes: 2 additions & 0 deletions app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
slashingkeeper "github.com/cosmos/cosmos-sdk/x/slashing/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
contractmanagerkeeper "github.com/neutron-org/neutron/x/contractmanager/keeper"
cronkeeper "github.com/neutron-org/neutron/x/cron/keeper"
feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper"
icqkeeper "github.com/neutron-org/neutron/x/interchainqueries/keeper"
Expand Down Expand Up @@ -42,6 +43,7 @@ type UpgradeKeepers struct {
ParamsKeeper paramskeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
BuilderKeeper builderkeeper.Keeper
ContractManager contractmanagerkeeper.Keeper
// subspaces
GlobalFeeSubspace paramtypes.Subspace
}
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,7 @@ github.com/json-iterator/go v1.1.8/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/u
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o=
Expand Down Expand Up @@ -908,6 +909,7 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJ
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8=
github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg=
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
Expand All @@ -928,6 +930,7 @@ github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OS
github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE=
github.com/neutron-org/admin-module v0.0.0-20230705134325-b23404470a1d h1:oexw79znoA0TEo7CGdWHrolbvZqCDD3aI+031CbOq9Y=
github.com/neutron-org/admin-module v0.0.0-20230705134325-b23404470a1d/go.mod h1:QuxQ7FJlEAFMRssyEYOrR9ORnYQvBFMTlO8BXny6ntw=
github.com/neutron-org/wasmd v0.40.0-rc.0.0.20230808084410-6083b888424e h1:uVJCBWf1vcCYY0pzOA2SCPIZT8WsR8fsOxs57mnJbM4=
github.com/neutron-org/wasmd v0.40.0-rc.0.0.20230808084410-6083b888424e/go.mod h1:Oagy36cU49438NzxKG/gmGTG903tiAI7LIUdH7x2qNY=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
2 changes: 1 addition & 1 deletion network/init-neutrond.sh
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,9 @@ set_genesis_param min_signed_per_window "\"$SLASHING_MIN_SIGNED\","
set_genesis_param slash_fraction_double_sign "\"$SLASHING_FRACTION_DOUBLE_SIGN\"," # slashing
set_genesis_param slash_fraction_downtime "\"$SLASHING_FRACTION_DOWNTIME\"" # slashing
set_genesis_param minimum_gas_prices "$MIN_GAS_PRICES" # globalfee

set_genesis_param proposer_fee "\"0.25\"" # builder(POB)
set_genesis_param escrow_account_address "\"$DAO_CONTRACT_ADDRESS_B64\"," # builder(POB)
set_genesis_param sudo_call_gas_limit "\"1000000\"" # contractmanager

if ! jq -e . "$GENESIS_PATH" >/dev/null 2>&1; then
echo "genesis appears to become incorrect json" >&2
Expand Down
5 changes: 4 additions & 1 deletion proto/neutron/contractmanager/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ import "gogoproto/gogo.proto";
option go_package = "github.com/neutron-org/neutron/x/contractmanager/types";

// Params defines the parameters for the module.
message Params { option (gogoproto.goproto_stringer) = false; }
message Params {
option (gogoproto.goproto_stringer) = false;
uint64 sudo_call_gas_limit = 1;
}
6 changes: 3 additions & 3 deletions proto/neutron/cron/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ option go_package = "github.com/neutron-org/neutron/x/cron/types";

// GenesisState defines the cron module's genesis state.
message GenesisState {
repeated Schedule scheduleList = 2 [(gogoproto.nullable) = false];
Params params = 1 [ (gogoproto.nullable) = false ];
// this line is used by starport scaffolding # genesis/proto/state
repeated Schedule scheduleList = 2 [ (gogoproto.nullable) = false ];
Params params = 1 [ (gogoproto.nullable) = false ];
// this line is used by starport scaffolding # genesis/proto/state
}
10 changes: 5 additions & 5 deletions proto/neutron/cron/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ option go_package = "github.com/neutron-org/neutron/x/cron/types";

// Params defines the parameters for the module.
message Params {
option (gogoproto.goproto_stringer) = false;
// Security address that can remove schedules
string security_address = 1;
// Limit of schedules executed in one block
uint64 limit = 2;
option (gogoproto.goproto_stringer) = false;
// Security address that can remove schedules
string security_address = 1;
// Limit of schedules executed in one block
uint64 limit = 2;
}
40 changes: 19 additions & 21 deletions proto/neutron/cron/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,43 @@ option go_package = "github.com/neutron-org/neutron/x/cron/types";
// Query defines the gRPC querier service.
service Query {
// Queries the parameters of the module.
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/neutron/cron/params";
}
rpc Params(QueryParamsRequest) returns (QueryParamsResponse) {
option (google.api.http).get = "/neutron/cron/params";
}

// Queries a Schedule by name.
rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) {
option (google.api.http).get = "/neutron/cron/schedule/{name}";
}
// Queries a Schedule by name.
rpc Schedule(QueryGetScheduleRequest) returns (QueryGetScheduleResponse) {
option (google.api.http).get = "/neutron/cron/schedule/{name}";
}

// Queries a list of Schedule items.
rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) {
option (google.api.http).get = "/neutron/cron/schedule";
}
// Queries a list of Schedule items.
rpc Schedules(QuerySchedulesRequest) returns (QuerySchedulesResponse) {
option (google.api.http).get = "/neutron/cron/schedule";
}

// this line is used by starport scaffolding # 2
// this line is used by starport scaffolding # 2
}

message QueryParamsRequest {}

message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [(gogoproto.nullable) = false];
// params holds all the parameters of this module.
Params params = 1 [ (gogoproto.nullable) = false ];
}

message QueryGetScheduleRequest {
string name = 1;
}
message QueryGetScheduleRequest { string name = 1; }

message QueryGetScheduleResponse {
Schedule schedule = 1 [(gogoproto.nullable) = false];
Schedule schedule = 1 [ (gogoproto.nullable) = false ];
}

message QuerySchedulesRequest {
cosmos.base.query.v1beta1.PageRequest pagination = 1;
cosmos.base.query.v1beta1.PageRequest pagination = 1;
}

message QuerySchedulesResponse {
repeated Schedule schedules = 1 [(gogoproto.nullable) = false];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
repeated Schedule schedules = 1 [ (gogoproto.nullable) = false ];
cosmos.base.query.v1beta1.PageResponse pagination = 2;
}

// this line is used by starport scaffolding # 3
28 changes: 14 additions & 14 deletions proto/neutron/cron/schedule.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ option go_package = "github.com/neutron-org/neutron/x/cron/types";
import "gogoproto/gogo.proto";

message Schedule {
// Name of schedule
string name = 1;
// Period in blocks
uint64 period = 2;
// Msgs that will be executed every period amount of time
repeated MsgExecuteContract msgs = 3 [ (gogoproto.nullable) = false ];
// Last execution's block height
uint64 last_execute_height = 4;
// Name of schedule
string name = 1;
// Period in blocks
uint64 period = 2;
// Msgs that will be executed every period amount of time
repeated MsgExecuteContract msgs = 3 [ (gogoproto.nullable) = false ];
// Last execution's block height
uint64 last_execute_height = 4;
}

message MsgExecuteContract {
// Contract is the address of the smart contract
string contract = 1;
// Msg is json encoded message to be passed to the contract
string msg = 2;
// Contract is the address of the smart contract
string contract = 1;
// Msg is json encoded message to be passed to the contract
string msg = 2;
}

message ScheduleCount {
// Count is the number of current schedules
int32 count = 1;
// Count is the number of current schedules
int32 count = 1;
}
3 changes: 1 addition & 2 deletions proto/neutron/cron/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ option go_package = "github.com/neutron-org/neutron/x/cron/types";

// Msg defines the Msg service.
service Msg {
// this line is used by starport scaffolding # proto/tx/rpc
// this line is used by starport scaffolding # proto/tx/rpc
}


// this line is used by starport scaffolding # proto/tx/message
3 changes: 1 addition & 2 deletions proto/neutron/transfer/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ message MsgTransfer {

string memo = 8;

neutron.feerefunder.Fee fee = 9
[ (gogoproto.nullable) = false ];
neutron.feerefunder.Fee fee = 9 [ (gogoproto.nullable) = false ];
}

// MsgTransferResponse is the modified response type for
Expand Down
18 changes: 10 additions & 8 deletions proto/osmosis/tokenfactory/v1beta1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import "cosmos/base/v1beta1/coin.proto";

// Params holds parameters for the tokenfactory module
message Params {
// DenomCreationFee is the fee required to create a new denom using the tokenfactory module
repeated cosmos.base.v1beta1.Coin denom_creation_fee = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
(gogoproto.nullable) = false
];
// DenomCreationFee is the fee required to create a new denom using the
// tokenfactory module
repeated cosmos.base.v1beta1.Coin denom_creation_fee = 1 [
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins",
(gogoproto.moretags) = "yaml:\"denom_creation_fee\"",
(gogoproto.nullable) = false
];

// FeeCollectorAddress is the address where fees collected from denom creation are sent to
string fee_collector_address = 2;
// FeeCollectorAddress is the address where fees collected from denom creation
// are sent to
string fee_collector_address = 2;
}
3 changes: 2 additions & 1 deletion proto/osmosis/tokenfactory/v1beta1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ service Query {
rpc DenomAuthorityMetadata(QueryDenomAuthorityMetadataRequest)
returns (QueryDenomAuthorityMetadataResponse) {
option (google.api.http).get =
"/osmosis/tokenfactory/v1beta1/denoms/factory/{creator}/{subdenom}/authority_metadata";
"/osmosis/tokenfactory/v1beta1/denoms/factory/{creator}/{subdenom}/"
"authority_metadata";
}

rpc DenomsFromCreator(QueryDenomsFromCreatorRequest)
Expand Down
14 changes: 14 additions & 0 deletions testutil/mocks/interchaintxs/types/expected_keepers.go

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

23 changes: 19 additions & 4 deletions testutil/mocks/transfer/types/expected_keepers.go

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

11 changes: 9 additions & 2 deletions x/contractmanager/keeper/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,15 @@ import (
)

// GetParams get all parameters as types.Params
func (k Keeper) GetParams(_ sdk.Context) types.Params {
return types.NewParams()
func (k Keeper) GetParams(ctx sdk.Context) (params types.Params) {
store := ctx.KVStore(k.storeKey)
bz := store.Get(types.ParamsKey)
if bz == nil {
return params
}

k.cdc.MustUnmarshal(bz, &params)
return params
}

// SetParams set the params
Expand Down
6 changes: 5 additions & 1 deletion x/contractmanager/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ import (

var _ paramtypes.ParamSet = (*Params)(nil)

const DefaultSudoCallGasLimit = uint64(1_000_000)

// ParamKeyTable the param key table for launch module
func ParamKeyTable() paramtypes.KeyTable {
return paramtypes.NewKeyTable().RegisterParamSet(&Params{})
}

// NewParams creates a new Params instance
func NewParams() Params {
return Params{}
return Params{
SudoCallGasLimit: DefaultSudoCallGasLimit,
}
}

// DefaultParams returns a default set of parameters
Expand Down
Loading

0 comments on commit 509e332

Please sign in to comment.