Skip to content
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: ictx + transfer with limited sudo call #NTRN-85 #304

Merged
merged 22 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
NeverHappened marked this conversation as resolved.
Show resolved Hide resolved
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...")
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
cmParams := contractmanagermoduletypes.Params{
SudoCallGasLimit: 1_000_000,
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
}
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
12 changes: 6 additions & 6 deletions network/hermes/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,41 +93,41 @@ port = 3001
id = 'test-1'
rpc_addr = 'http://127.0.0.1:26657'
grpc_addr = 'http://127.0.0.1:8090'
websocket_addr = 'ws://127.0.0.1:26657/websocket'
event_source = { mode = 'push', url = 'ws://127.0.0.1:26657/websocket', batch_delay = '200ms' }
rpc_timeout = '10s'
account_prefix = 'neutron'
key_name = 'testkey_1'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.0025, denom = 'untrn' }
gas_multiplier = 1.1
gas_multiplier = 1.5
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
ccv_consumer_chain = true
trust_threshold = { numerator = '1', denominator = '3' }
unbonding_period = '20days'
address_type = { derivation = 'cosmos' }

[[chains]]
id = 'test-2'
rpc_addr = 'http://127.0.0.1:16657'
grpc_addr = 'http://127.0.0.1:9090'
websocket_addr = 'ws://127.0.0.1:16657/websocket'
event_source = { mode = 'push', url = 'ws://127.0.0.1:16657/websocket', batch_delay = '200ms' }
rpc_timeout = '10s'
account_prefix = 'cosmos'
key_name = 'testkey_2'
store_prefix = 'ibc'
default_gas = 100000
max_gas = 3000000
gas_price = { price = 0.0025, denom = 'uatom' }
gas_multiplier = 1.1
gas_multiplier = 1.5
max_msg_num = 30
max_tx_size = 2097152
clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
address_type = { derivation = 'cosmos' }
5 changes: 2 additions & 3 deletions network/init-neutrond.sh
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,11 @@ set_genesis_param signed_blocks_window "\"$SLASHING_SIGNED_BLO
set_genesis_param min_signed_per_window "\"$SLASHING_MIN_SIGNED\"," # slashing
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 max_total_bypass_min_fee_msg_gas_usage "\"$MAX_TOTAL_BYPASS_MIN_FEE_MSG_GAS_USAGE\"" # globalfee
set_genesis_param minimum_gas_prices "$MIN_GAS_PRICES," # globalfeeset_genesis_param max_total_bypass_min_fee_msg_gas_usage "\"$MAX_TOTAL_BYPASS_MIN_FEE_MSG_GAS_USAGE\"" # globalfee
NeverHappened marked this conversation as resolved.
Show resolved Hide resolved
set_genesis_param_jq ".app_state.globalfee.params.bypass_min_fee_msg_types" "$BYPASS_MIN_FEE_MSG_TYPES" # 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
21 changes: 21 additions & 0 deletions neutronutils/errors/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package errors

import (
"cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// OutOfGasRecovery converts `out of gas` panic into an error
// leave unprocessed any other kinds of panics
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
func OutOfGasRecovery(
gasMeter sdk.GasMeter,
err *error,
) {
if r := recover(); r != nil {
_, ok := r.(sdk.ErrorOutOfGas)
if !ok || !gasMeter.IsOutOfGas() {
panic(r)
}
*err = errors.Wrapf(errors.ErrPanic, "%v", r)
}
}
11 changes: 11 additions & 0 deletions neutronutils/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package neutronutils
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved

import sdk "github.com/cosmos/cosmos-sdk/types"

// CreateCachedContext creates a cached context for with a limited gas meter.
swelf19 marked this conversation as resolved.
Show resolved Hide resolved
func CreateCachedContext(ctx sdk.Context, gasLimit uint64) (sdk.Context, func(), sdk.GasMeter) {
cacheCtx, writeFn := ctx.CacheContext()
gasMeter := sdk.NewGasMeter(gasLimit)
cacheCtx = cacheCtx.WithGasMeter(gasMeter)
return cacheCtx, writeFn, gasMeter
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
}
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.

Loading