Skip to content

Commit

Permalink
Feature/add msgs per tx to proposals (#365)
Browse files Browse the repository at this point in the history
* add message_per_tx to RegisterZoneProposal and UpdateZoneProposal

* update changelog

* bump upgrade handler to v1.2.9 to match release

* add validate basic test

* add v1.2.8 to retractions
  • Loading branch information
Joe Bowman authored Mar 28, 2023
1 parent c3105a8 commit ee5349e
Show file tree
Hide file tree
Showing 10 changed files with 356 additions and 70 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Released

### v1.2.9
- Add message_per_tx param to zone registration and update proposals

### v1.2.8
- Add feature to configure max-tx size per zone
- Set `ICATimeout` to 6h
Expand Down
6 changes: 3 additions & 3 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ const (

v010204UpgradeName = "v1.2.4"
v010207UpgradeName = "v1.2.7"
v010208UpgradeName = "v1.2.8"
v010209UpgradeName = "v1.2.9"
v010300UpgradeName = "v1.3.0" // retained for testy
)

func setUpgradeHandlers(app *Quicksilver) {
app.UpgradeKeeper.SetUpgradeHandler(v010300UpgradeName, noOpUpgradeHandler(app)) // retained for testy
app.UpgradeKeeper.SetUpgradeHandler(v010204UpgradeName, v010204UpgradeHandler(app))
app.UpgradeKeeper.SetUpgradeHandler(v010207UpgradeName, v010207UpgradeHandler(app))
app.UpgradeKeeper.SetUpgradeHandler(v010208UpgradeName, v010208UpgradeHandler(app))
app.UpgradeKeeper.SetUpgradeHandler(v010209UpgradeName, v010209UpgradeHandler(app))

// When a planned update height is reached, the old binary will panic
// writing on disk the height and name of the update that triggered it
Expand Down Expand Up @@ -105,7 +105,7 @@ func v010207UpgradeHandler(app *Quicksilver) upgradetypes.UpgradeHandler {
}
}

func v010208UpgradeHandler(app *Quicksilver) upgradetypes.UpgradeHandler {
func v010209UpgradeHandler(app *Quicksilver) upgradetypes.UpgradeHandler {
return func(ctx sdk.Context, _ upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// set messages per tx a maximum of (max_gas per tx/block divided by 1m); be conservative for now and we can tweak later.

Expand Down
4 changes: 2 additions & 2 deletions app/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ func (s *AppTestSuite) TestV010207UpgradeHandler() {
s.Require().Equal(expectedProportions, params.DistributionProportions)
}

func (s *AppTestSuite) TestV010208UpgradeHandler() {
func (s *AppTestSuite) TestV010209UpgradeHandler() {
app := s.GetQuicksilverApp(s.chainA)

// cosmos zone
Expand Down Expand Up @@ -355,7 +355,7 @@ func (s *AppTestSuite) TestV010208UpgradeHandler() {
}
app.InterchainstakingKeeper.SetZone(s.chainA.GetContext(), &zone)

handler := v010208UpgradeHandler(app)
handler := v010209UpgradeHandler(app)
ctx := s.chainA.GetContext()

_, err := handler(ctx, types.Plan{}, app.mm.GetVersionMap())
Expand Down
10 changes: 7 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
cosmossdk.io/math v1.0.0-beta.4
github.com/CosmWasm/wasmd v0.29.2
github.com/client9/misspell v0.3.4
github.com/cometbft/cometbft-db v0.7.0
github.com/cosmos/cosmos-proto v1.0.0-alpha8
github.com/cosmos/cosmos-sdk v0.46.11
github.com/cosmos/ibc-go/v5 v5.2.0
Expand Down Expand Up @@ -56,7 +57,6 @@ require (
github.com/butuzov/ireturn v0.1.1 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.0.0-20230227094218-b8c73b2037b8 // indirect
github.com/cometbft/cometbft-db v0.7.0 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/daixiang0/gci v0.10.1 // indirect
github.com/denis-tingaikin/go-header v0.4.3 // indirect
Expand Down Expand Up @@ -288,7 +288,7 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5
github.com/subosito/gotenv v1.4.2 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect
github.com/tendermint/go-amino v0.16.0 // indirect
github.com/tidwall/btree v1.5.0 // indirect
Expand Down Expand Up @@ -325,4 +325,8 @@ replace (
)

// do not use
retract [v1.2.5, v1.2.6]
retract (
v1.2.8 // unreleased
v1.2.6 // unreleased
v1.2.5 // unreleased
)
2 changes: 2 additions & 0 deletions proto/quicksilver/interchainstaking/v1/proposals.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ message RegisterZoneProposal {
[ (gogoproto.moretags) = "yaml:\"account_prefix\"" ];
bool multi_send = 7;
bool liquidity_module = 8;
int64 messages_per_tx = 9;
}

message RegisterZoneProposalWithDeposit {
Expand All @@ -40,6 +41,7 @@ message RegisterZoneProposalWithDeposit {
bool liquidity_module = 8
[ (gogoproto.moretags) = "yaml:\"liquidity_module\"" ];
string deposit = 9 [ (gogoproto.moretags) = "yaml:\"deposit\"" ];
int64 messages_per_tx = 10;
}

message UpdateZoneProposal {
Expand Down
5 changes: 5 additions & 0 deletions x/interchainstaking/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Where proposal.json contains:
"account_prefix": "cosmos",
"multi_send": true,
"liquidity_module": false,
"messages_per_tx": "5",
"deposit": "512000000uqck"
}
`),
Expand All @@ -163,6 +164,10 @@ Where proposal.json contains:
return err
}

if proposal.MessagesPerTx < 1 {
return errors.New("messages_per_tx must be a positive non-zero integer")
}

deposit, err := sdk.ParseCoinsNormalized(proposal.Deposit)
if err != nil {
return err
Expand Down
10 changes: 10 additions & 0 deletions x/interchainstaking/keeper/proposal_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,16 @@ func HandleUpdateZoneProposal(ctx sdk.Context, k Keeper, p *types.UpdateZoneProp
}
zone.LiquidityModule = boolValue

case "messages_per_tx":
intVal, err := strconv.Atoi(change.Value)
if err != nil {
return err
}
if intVal < 1 {
return errors.New("invalid value for messages_per_tx")
}
zone.MessagesPerTx = int64(intVal)

case "connection_id":
if !strings.HasPrefix(change.Value, "connection-") {
return errors.New("unexpected connection format")
Expand Down
12 changes: 11 additions & 1 deletion x/interchainstaking/types/proposals.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (m RegisterZoneProposal) ValidateBasic() error {
}

// check valid connection id
if len(m.ConnectionId) < 12 {
return fmt.Errorf("invalid length connection string: %s", m.ConnectionId)
}

if m.ConnectionId[0:11] != "connection-" {
return fmt.Errorf("invalid connection string: %s", m.ConnectionId)
}
Expand All @@ -55,6 +59,11 @@ func (m RegisterZoneProposal) ValidateBasic() error {
return errors.New("account prefix must be at least 2 characters") // ki is shortest to date.
}

// validate messages_per_tx
if m.MessagesPerTx < 1 {
return errors.New("messages_per_tx must be a positive non-zero integer")
}

if m.LiquidityModule {
return errors.New("liquidity module is unsupported")
}
Expand All @@ -71,7 +80,8 @@ func (m RegisterZoneProposal) String() string {
Local Denom: %s
Multi Send Enabled: %t
Liquidity Staking Module Enabled: %t
`, m.Title, m.Description, m.ConnectionId, m.BaseDenom, m.LocalDenom, m.MultiSend, m.LiquidityModule)
Messages per Tx: %d
`, m.Title, m.Description, m.ConnectionId, m.BaseDenom, m.LocalDenom, m.MultiSend, m.LiquidityModule, m.MessagesPerTx)
}

func NewUpdateZoneProposal(title string, description string, chainID string, changes []*UpdateZoneValue) *UpdateZoneProposal {
Expand Down
Loading

0 comments on commit ee5349e

Please sign in to comment.