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 all 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
11 changes: 8 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func New(
app.BankKeeper,
scopedTransferKeeper,
app.FeeKeeper,
app.ContractManagerKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
)

app.RouterKeeper.SetTransferKeeper(app.TransferKeeper.Keeper)
Expand Down Expand Up @@ -633,8 +633,10 @@ func New(
memKeys[interchaintxstypes.MemStoreKey],
app.IBCKeeper.ChannelKeeper,
app.ICAControllerKeeper,
app.ContractManagerKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
app.FeeKeeper,
app.BankKeeper,
app.FeeBurnerKeeper,
)

app.CronKeeper = *cronkeeper.NewKeeper(appCodec, keys[crontypes.StoreKey], keys[crontypes.MemStoreKey], app.AccountKeeper)
Expand Down Expand Up @@ -669,7 +671,10 @@ func New(
app.CronKeeper.WasmMsgServer = wasmkeeper.NewMsgServerImpl(&app.WasmKeeper)
cronModule := cron.NewAppModule(appCodec, &app.CronKeeper)

transferIBCModule := transferSudo.NewIBCModule(app.TransferKeeper)
transferIBCModule := transferSudo.NewIBCModule(
app.TransferKeeper,
contractmanager.NewSudoLimitWrapper(app.ContractManagerKeeper, &app.WasmKeeper),
)
// receive call order: wasmHooks#OnRecvPacketOverride(transferIbcModule#OnRecvPacket())
ibcHooksMiddleware := ibchooks.NewIBCMiddleware(&transferIBCModule, &app.HooksICS4Wrapper)
app.HooksTransferIBCModule = &ibcHooksMiddleware
Expand Down
46 changes: 34 additions & 12 deletions app/upgrades/sdk47/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ 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"
contractmanagerkeeper "github.com/neutron-org/neutron/x/contractmanager/keeper"
contractmanagertypes "github.com/neutron-org/neutron/x/contractmanager/types"
crontypes "github.com/neutron-org/neutron/x/cron/types"
feeburnerkeeper "github.com/neutron-org/neutron/x/feeburner/keeper"
feeburnertypes "github.com/neutron-org/neutron/x/feeburner/types"
feerefundertypes "github.com/neutron-org/neutron/x/feerefunder/types"
icqtypes "github.com/neutron-org/neutron/x/interchainqueries/types"
interchaintxstypes "github.com/neutron-org/neutron/x/interchaintxs/types"
tokenfactorytypes "github.com/neutron-org/neutron/x/tokenfactory/types"
builderkeeper "github.com/skip-mev/pob/x/builder/keeper"
buildertypes "github.com/skip-mev/pob/x/builder/types"
)

Expand Down Expand Up @@ -72,21 +76,13 @@ func CreateUpgradeHandler(
}

ctx.Logger().Info("Setting pob params...")
treasury := keepers.FeeBurnerKeeper.GetParams(ctx).TreasuryAddress
_, data, err := bech32.DecodeAndConvert(treasury)
err = setPobParams(ctx, keepers.FeeBurnerKeeper, keepers.BuilderKeeper)
if err != nil {
return nil, err
}

builderParams := buildertypes.Params{
MaxBundleSize: 2,
EscrowAccountAddress: data,
ReserveFee: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)},
MinBidIncrement: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)},
FrontRunningProtection: true,
ProposerFee: math.LegacyNewDecWithPrec(25, 2),
}
err = keepers.BuilderKeeper.SetParams(ctx, builderParams)
ctx.Logger().Info("Setting sudo callback limit...")
sotnikov-s marked this conversation as resolved.
Show resolved Hide resolved
err = setContractManagerParams(ctx, keepers.ContractManager)
if err != nil {
return nil, err
}
Expand All @@ -96,6 +92,31 @@ func CreateUpgradeHandler(
}
}

func setPobParams(ctx sdk.Context, feeBurnerKeeper *feeburnerkeeper.Keeper, builderKeeper builderkeeper.Keeper) error {
treasury := feeBurnerKeeper.GetParams(ctx).TreasuryAddress
_, data, err := bech32.DecodeAndConvert(treasury)
if err != nil {
return err
}

builderParams := buildertypes.Params{
MaxBundleSize: 2,
EscrowAccountAddress: data,
ReserveFee: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)},
MinBidIncrement: sdk.Coin{Denom: "untrn", Amount: sdk.NewInt(1_000_000)},
FrontRunningProtection: true,
ProposerFee: math.LegacyNewDecWithPrec(25, 2),
}
return builderKeeper.SetParams(ctx, builderParams)
}

func setContractManagerParams(ctx sdk.Context, keeper contractmanagerkeeper.Keeper) error {
cmParams := contractmanagertypes.Params{
SudoCallGasLimit: contractmanagertypes.DefaultSudoCallGasLimit,
}
return keeper.SetParams(ctx, cmParams)
}

func migrateCronParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error {
store := ctx.KVStore(storeKey)
var currParams crontypes.Params
Expand All @@ -114,7 +135,7 @@ func migrateCronParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, store
func migrateFeeRefunderParams(ctx sdk.Context, paramsKeepers paramskeeper.Keeper, storeKey storetypes.StoreKey, codec codec.Codec) error {
store := ctx.KVStore(storeKey)
var currParams feerefundertypes.Params
subspace, _ := paramsKeepers.GetSubspace(crontypes.StoreKey)
subspace, _ := paramsKeepers.GetSubspace(feerefundertypes.StoreKey)
subspace.GetParamSet(ctx, &currParams)

if err := currParams.Validate(); err != nil {
Expand Down Expand Up @@ -176,6 +197,7 @@ func migrateInterchainTxsParams(ctx sdk.Context, paramsKeepers paramskeeper.Keep
var currParams interchaintxstypes.Params
subspace, _ := paramsKeepers.GetSubspace(interchaintxstypes.StoreKey)
subspace.GetParamSet(ctx, &currParams)
currParams.RegisterFee = interchaintxstypes.DefaultRegisterFee

if err := currParams.Validate(); err != nil {
return err
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
CcvConsumerSubspace 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' }
4 changes: 2 additions & 2 deletions network/init-neutrond.sh
Original file line number Diff line number Diff line change
Expand Up @@ -637,12 +637,12 @@ 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 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_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
8 changes: 2 additions & 6 deletions proto/neutron/contractmanager/failure.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ message Failure {
string address = 1;
// Id of the failure under specific address
uint64 id = 2;
// Acknowledgement type
string ack_type = 3;
// IBC Packet
ibc.core.channel.v1.Packet packet = 4;
// Acknowledgement
ibc.core.channel.v1.Acknowledgement ack = 5;
// Serialized MessageSudoCallback with Packet and Ack(if exists)
bytes sudo_payload = 3;
}
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: 3 additions & 0 deletions proto/neutron/interchaintxs/v1/params.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package neutron.interchaintxs;

import "gogoproto/gogo.proto";
import "cosmos/base/v1beta1/coin.proto";

option go_package = "github.com/neutron-org/neutron/x/interchaintxs/types";

Expand All @@ -10,4 +11,6 @@ message Params {
option (gogoproto.goproto_stringer) = false;
// Defines maximum amount of messages to be passed in MsgSubmitTx
uint64 msg_submit_tx_max_messages = 1;
// Defines a minimum fee required to register interchain account
repeated cosmos.base.v1beta1.Coin register_fee = 2 [ (gogoproto.nullable) = false ];
}
5 changes: 5 additions & 0 deletions proto/neutron/interchaintxs/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package neutron.interchaintxs.v1;
option go_package = "github.com/neutron-org/neutron/x/interchaintxs/types";

import "cosmos_proto/cosmos.proto";
import "cosmos/base/v1beta1/coin.proto";
import "gogoproto/gogo.proto";
import "google/api/http.proto";
import "google/api/annotations.proto";
Expand All @@ -26,6 +27,10 @@ message MsgRegisterInterchainAccount {
string connection_id = 2 [ (gogoproto.moretags) = "yaml:\"connection_id\"" ];
string interchain_account_id = 3
[ (gogoproto.moretags) = "yaml:\"interchain_account_id\"" ];
repeated cosmos.base.v1beta1.Coin register_fee = 4 [
(gogoproto.nullable) = false,
(gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"
];
}

// MsgRegisterInterchainAccountResponse is the response type for
Expand Down
Loading
Loading