From ee5349ef0b123cd6ea4ed54769dd26c0717f7821 Mon Sep 17 00:00:00 2001 From: Joe Bowman Date: Tue, 28 Mar 2023 17:05:03 +0100 Subject: [PATCH] Feature/add msgs per tx to proposals (#365) * 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 --- CHANGELOG.md | 3 + app/upgrades.go | 6 +- app/upgrades_test.go | 4 +- go.mod | 10 +- .../interchainstaking/v1/proposals.proto | 2 + x/interchainstaking/client/cli/tx.go | 5 + .../keeper/proposal_handler.go | 10 + x/interchainstaking/types/proposals.go | 12 +- x/interchainstaking/types/proposals.pb.go | 164 +++++++++----- x/interchainstaking/types/proposals_test.go | 210 +++++++++++++++++- 10 files changed, 356 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cab0865d2..e86d56908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/app/upgrades.go b/app/upgrades.go index 4a37a3188..5ed39cee8 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -19,7 +19,7 @@ const ( v010204UpgradeName = "v1.2.4" v010207UpgradeName = "v1.2.7" - v010208UpgradeName = "v1.2.8" + v010209UpgradeName = "v1.2.9" v010300UpgradeName = "v1.3.0" // retained for testy ) @@ -27,7 +27,7 @@ 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 @@ -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. diff --git a/app/upgrades_test.go b/app/upgrades_test.go index f5fc8b836..b410bf49d 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -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 @@ -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()) diff --git a/go.mod b/go.mod index 9197c28e2..464dd53f9 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 @@ -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 @@ -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 +) diff --git a/proto/quicksilver/interchainstaking/v1/proposals.proto b/proto/quicksilver/interchainstaking/v1/proposals.proto index 3f24a6588..7d022d10a 100644 --- a/proto/quicksilver/interchainstaking/v1/proposals.proto +++ b/proto/quicksilver/interchainstaking/v1/proposals.proto @@ -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 { @@ -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 { diff --git a/x/interchainstaking/client/cli/tx.go b/x/interchainstaking/client/cli/tx.go index 6001b4933..a2d9497b6 100644 --- a/x/interchainstaking/client/cli/tx.go +++ b/x/interchainstaking/client/cli/tx.go @@ -140,6 +140,7 @@ Where proposal.json contains: "account_prefix": "cosmos", "multi_send": true, "liquidity_module": false, + "messages_per_tx": "5", "deposit": "512000000uqck" } `), @@ -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 diff --git a/x/interchainstaking/keeper/proposal_handler.go b/x/interchainstaking/keeper/proposal_handler.go index 3f8c49ada..371aa2717 100644 --- a/x/interchainstaking/keeper/proposal_handler.go +++ b/x/interchainstaking/keeper/proposal_handler.go @@ -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") diff --git a/x/interchainstaking/types/proposals.go b/x/interchainstaking/types/proposals.go index 2e220c5aa..a0fc1e16e 100644 --- a/x/interchainstaking/types/proposals.go +++ b/x/interchainstaking/types/proposals.go @@ -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) } @@ -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") } @@ -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 { diff --git a/x/interchainstaking/types/proposals.pb.go b/x/interchainstaking/types/proposals.pb.go index 3cad2a197..cb5e24c26 100644 --- a/x/interchainstaking/types/proposals.pb.go +++ b/x/interchainstaking/types/proposals.pb.go @@ -34,6 +34,7 @@ type RegisterZoneProposal struct { AccountPrefix string `protobuf:"bytes,6,opt,name=account_prefix,json=accountPrefix,proto3" json:"account_prefix,omitempty" yaml:"account_prefix"` MultiSend bool `protobuf:"varint,7,opt,name=multi_send,json=multiSend,proto3" json:"multi_send,omitempty"` LiquidityModule bool `protobuf:"varint,8,opt,name=liquidity_module,json=liquidityModule,proto3" json:"liquidity_module,omitempty"` + MessagesPerTx int64 `protobuf:"varint,9,opt,name=messages_per_tx,json=messagesPerTx,proto3" json:"messages_per_tx,omitempty"` } func (m *RegisterZoneProposal) Reset() { *m = RegisterZoneProposal{} } @@ -78,6 +79,7 @@ type RegisterZoneProposalWithDeposit struct { MultiSend bool `protobuf:"varint,7,opt,name=multi_send,json=multiSend,proto3" json:"multi_send,omitempty" yaml:"multi_send"` LiquidityModule bool `protobuf:"varint,8,opt,name=liquidity_module,json=liquidityModule,proto3" json:"liquidity_module,omitempty" yaml:"liquidity_module"` Deposit string `protobuf:"bytes,9,opt,name=deposit,proto3" json:"deposit,omitempty" yaml:"deposit"` + MessagesPerTx int64 `protobuf:"varint,10,opt,name=messages_per_tx,json=messagesPerTx,proto3" json:"messages_per_tx,omitempty"` } func (m *RegisterZoneProposalWithDeposit) Reset() { *m = RegisterZoneProposalWithDeposit{} } @@ -420,59 +422,61 @@ func init() { } var fileDescriptor_04d034c830a7acfe = []byte{ - // 819 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x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, 0x4f, 0x14, 0xe9, 0x5c, 0x7e, 0x77, 0xdf, 0xd4, 0xee, 0xee, 0x9b, 0xda, - 0x4f, 0xf7, 0x4d, 0xed, 0x8b, 0x87, 0x66, 0xe9, 0xee, 0xa1, 0x59, 0xfa, 0xf1, 0xa1, 0x59, 0xba, - 0x3c, 0x72, 0xa9, 0xec, 0x87, 0xbd, 0xb6, 0xcd, 0x87, 0x26, 0x65, 0x2e, 0x61, 0x21, 0x95, 0xe3, - 0xbd, 0x5e, 0x48, 0x3d, 0xc7, 0x2c, 0xbe, 0xc6, 0xae, 0x17, 0xbc, 0xc7, 0xe4, 0xd8, 0x27, 0xa2, - 0xb7, 0xa2, 0x1e, 0x46, 0x6f, 0xff, 0x16, 0x00, 0x00, 0xff, 0xff, 0x97, 0x81, 0x7a, 0xe0, 0xbd, - 0x09, 0x00, 0x00, + // 854 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe4, 0x56, 0xcd, 0x6f, 0xdc, 0x44, + 0x14, 0x5f, 0x67, 0xf3, 0xb5, 0x93, 0xaf, 0x32, 0xdd, 0x82, 0x9b, 0x36, 0xeb, 0xd5, 0x1c, 0xaa, + 0x20, 0xe8, 0x9a, 0x40, 0x04, 0xa8, 0x12, 0x52, 0xd9, 0x56, 0xa0, 0x1c, 0x2a, 0x45, 0x53, 0x3e, + 0xa4, 0x70, 0xb0, 0x1c, 0xfb, 0xe1, 0x1d, 0xc5, 0x3b, 0xe3, 0x7a, 0xc6, 0xab, 0xec, 0x7f, 0xd0, + 0x23, 0x17, 0x24, 0x8e, 0xf9, 0x23, 0x38, 0x73, 0x46, 0x9c, 0x0a, 0x27, 0x4e, 0x16, 0x4a, 0x2e, + 0x5c, 0xf1, 0x95, 0x0b, 0xf2, 0xd8, 0x8b, 0xbd, 0x1f, 0xa8, 0x07, 0x44, 0x40, 0xe2, 0xf6, 0xde, + 0xfb, 0xbd, 0xdf, 0xd8, 0xf3, 0x7b, 0x3f, 0x8f, 0x07, 0xbd, 0xf5, 0x2c, 0x61, 0xde, 0x99, 0x64, + 0xe1, 0x08, 0x62, 0x9b, 0x71, 0x05, 0xb1, 0x37, 0x70, 0x19, 0x97, 0xca, 0x3d, 0x63, 0x3c, 0xb0, + 0x47, 0x07, 0x76, 0x14, 0x8b, 0x48, 0x48, 0x37, 0x94, 0xbd, 0x28, 0x16, 0x4a, 0xe0, 0x6e, 0x8d, + 0xd1, 0x9b, 0x63, 0xf4, 0x46, 0x07, 0xbb, 0xed, 0x40, 0x04, 0x42, 0x37, 0xdb, 0x79, 0x54, 0xf0, + 0x76, 0x6f, 0x7b, 0x42, 0x0e, 0x85, 0x74, 0x0a, 0xa0, 0x48, 0x4a, 0xe8, 0x6e, 0x20, 0x44, 0x10, + 0x82, 0xed, 0x46, 0xcc, 0x76, 0x39, 0x17, 0xca, 0x55, 0x4c, 0xf0, 0x12, 0x25, 0xdf, 0x35, 0x51, + 0x9b, 0x42, 0xc0, 0xa4, 0x82, 0xf8, 0x44, 0x70, 0x38, 0x2e, 0x5f, 0x08, 0xb7, 0xd1, 0x8a, 0x62, + 0x2a, 0x04, 0xd3, 0xe8, 0x1a, 0xfb, 0x2d, 0x5a, 0x24, 0xb8, 0x8b, 0x36, 0x7c, 0x90, 0x5e, 0xcc, + 0xa2, 0x7c, 0x11, 0x73, 0x49, 0x63, 0xf5, 0x12, 0xfe, 0x00, 0x6d, 0x79, 0x82, 0x73, 0xf0, 0xf2, + 0xcc, 0x61, 0xbe, 0xd9, 0xcc, 0x7b, 0xfa, 0x66, 0x96, 0x5a, 0xed, 0xb1, 0x3b, 0x0c, 0x1f, 0x90, + 0x29, 0x98, 0xd0, 0xcd, 0x2a, 0x3f, 0xf2, 0xf1, 0x21, 0x42, 0xa7, 0xae, 0x04, 0xc7, 0x07, 0x2e, + 0x86, 0xe6, 0xb2, 0xe6, 0xde, 0xca, 0x52, 0xeb, 0x95, 0x82, 0x5b,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dd, 0xf9, 0x82, 0xfb, 0x9d, 0x1a, + 0x47, 0x20, 0x4f, 0x57, 0xf5, 0x45, 0xeb, 0x9d, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0xa4, 0x71, + 0xe0, 0x5d, 0x0d, 0x0a, 0x00, 0x00, } func (m *RegisterZoneProposal) Marshal() (dAtA []byte, err error) { @@ -495,6 +499,11 @@ func (m *RegisterZoneProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.MessagesPerTx != 0 { + i = encodeVarintProposals(dAtA, i, uint64(m.MessagesPerTx)) + i-- + dAtA[i] = 0x48 + } if m.LiquidityModule { i-- if m.LiquidityModule { @@ -580,6 +589,11 @@ func (m *RegisterZoneProposalWithDeposit) MarshalToSizedBuffer(dAtA []byte) (int _ = i var l int _ = l + if m.MessagesPerTx != 0 { + i = encodeVarintProposals(dAtA, i, uint64(m.MessagesPerTx)) + i-- + dAtA[i] = 0x50 + } if len(m.Deposit) > 0 { i -= len(m.Deposit) copy(dAtA[i:], m.Deposit) @@ -1021,6 +1035,9 @@ func (m *RegisterZoneProposal) Size() (n int) { if m.LiquidityModule { n += 2 } + if m.MessagesPerTx != 0 { + n += 1 + sovProposals(uint64(m.MessagesPerTx)) + } return n } @@ -1064,6 +1081,9 @@ func (m *RegisterZoneProposalWithDeposit) Size() (n int) { if l > 0 { n += 1 + l + sovProposals(uint64(l)) } + if m.MessagesPerTx != 0 { + n += 1 + sovProposals(uint64(m.MessagesPerTx)) + } return n } @@ -1485,6 +1505,25 @@ func (m *RegisterZoneProposal) Unmarshal(dAtA []byte) error { } } m.LiquidityModule = bool(v != 0) + case 9: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MessagesPerTx", wireType) + } + m.MessagesPerTx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposals + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MessagesPerTx |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipProposals(dAtA[iNdEx:]) @@ -1799,6 +1838,25 @@ func (m *RegisterZoneProposalWithDeposit) Unmarshal(dAtA []byte) error { } m.Deposit = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 10: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MessagesPerTx", wireType) + } + m.MessagesPerTx = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowProposals + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MessagesPerTx |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipProposals(dAtA[iNdEx:]) diff --git a/x/interchainstaking/types/proposals_test.go b/x/interchainstaking/types/proposals_test.go index e19aa5a46..cc2f38daa 100644 --- a/x/interchainstaking/types/proposals_test.go +++ b/x/interchainstaking/types/proposals_test.go @@ -17,13 +17,207 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { AccountPrefix string MultiSend bool LiquidityModule bool + MessagesPerTx int64 } + tests := []struct { - name string - fields fields - wantErr bool + name string + fields fields + wantErr bool + errorMsg string }{ - // TODO: Add test cases. + { + "zero-length-title", + fields{ + "", + "description", + "connection-0", + "uatom", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "proposal title cannot be blank: invalid proposal content", + }, + { + "zero-length-desc", + fields{ + "title", + "", + "connection-0", + "uatom", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "proposal description cannot be blank: invalid proposal content", + }, + { + "zero-length-connection", + fields{ + "title", + "description", + "", + "uatom", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "invalid length connection string: ", + }, + { + "invalid-connection", + fields{ + "title", + "description", + "abcdefghijklmnop", + "uatom", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "invalid connection string: abcdefghijklmnop", + }, + { + "invalid-length-base-denom", + fields{ + "title", + "description", + "connection-0", + "", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "invalid denom: ", + }, + { + "invalid-base-denom", + fields{ + "title", + "description", + "connection-0", + "000", + "uqatom", + "cosmos", + true, + false, + 5, + }, + true, + "invalid denom: 000", + }, + { + "invalid-length-local-denom", + fields{ + "title", + "description", + "connection-0", + "uatom", + "", + "cosmos", + true, + false, + 5, + }, + true, + "invalid denom: ", + }, + { + "invalid-length-local-denom", + fields{ + "title", + "description", + "connection-0", + "uatom", + "0000", + "cosmos", + true, + false, + 5, + }, + true, + "invalid denom: 000", + }, + { + "invalid-length-prefix", + fields{ + "title", + "description", + "connection-0", + "uatom", + "uqatom", + "a", + true, + false, + 5, + }, + true, + "account prefix must be at least 2 characters", + }, + { + "invalid-messages-per-tx-0", + fields{ + "title", + "description", + "connection-0", + "uatom", + "uqatom", + "ki", + true, + false, + 0, + }, + true, + "messages_per_tx must be a positive non-zero integer", + }, + { + "invalid-messages-per-tx-negative", + fields{ + "title", + "description", + "connection-0", + "uatom", + "uqatom", + "cosmos", + true, + false, + -1, + }, + true, + "messages_per_tx must be a positive non-zero integer", + }, + { + "invalid-messages-per-tx-negative", + fields{ + "title", + "description", + "connection-0", + "uatom", + "uqatom", + "cosmos", + true, + false, + 50, + }, + false, + "", + }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -36,15 +230,15 @@ func TestRegisterZoneProposal_ValidateBasic(t *testing.T) { AccountPrefix: tt.fields.AccountPrefix, MultiSend: tt.fields.MultiSend, LiquidityModule: tt.fields.LiquidityModule, + MessagesPerTx: tt.fields.MessagesPerTx, } err := m.ValidateBasic() if tt.wantErr { - t.Logf("Error:\n%v\n", err) - require.Error(t, err) - return + require.ErrorContains(t, err, tt.errorMsg) + } else { + require.NoError(t, err) } - require.NoError(t, err) }) } }