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: removal message #772

Merged
merged 42 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
594d6b7
init proto
aljo242 Sep 17, 2024
c22b466
gen proto:
aljo242 Sep 17, 2024
44b9fc5
Merge branch 'main' into feat/removal-msg
aljo242 Sep 20, 2024
5364064
validate basic
aljo242 Sep 20, 2024
e812c89
test
aljo242 Sep 20, 2024
0d0e239
interface registry
aljo242 Sep 20, 2024
4ca8ad9
delete enabled
aljo242 Sep 20, 2024
62776ab
msg handler
aljo242 Sep 20, 2024
fb64aed
init test
aljo242 Sep 20, 2024
8e0081e
format
aljo242 Sep 20, 2024
0e55072
hooks and mocks
aljo242 Sep 20, 2024
a749d36
hooks
aljo242 Sep 20, 2024
d00d7e3
testingtown
aljo242 Sep 20, 2024
a69fe19
update
aljo242 Sep 20, 2024
bfcd9b8
todos
aljo242 Sep 23, 2024
786d3bc
Merge branch 'main' into feat/removal-msg
aljo242 Sep 23, 2024
4ab6bfe
admin
aljo242 Sep 23, 2024
5b07a79
admin fix
aljo242 Sep 23, 2024
713c7eb
test
aljo242 Sep 23, 2024
4cfbb95
clean
aljo242 Sep 23, 2024
68414d8
test
aljo242 Sep 23, 2024
bc9c93c
Merge branch 'main' into feat/removal-msg
aljo242 Sep 23, 2024
c0f9cc0
Merge branch 'main' into feat/removal-msg
aljo242 Sep 24, 2024
205f63d
clean
aljo242 Sep 24, 2024
730d774
some logs
aljo242 Sep 24, 2024
a6c710b
keep enabled in integ
aljo242 Sep 24, 2024
77d2b69
format
aljo242 Sep 24, 2024
ef2383f
Merge branch 'main' into feat/removal-msg
aljo242 Sep 24, 2024
02886b9
Merge branch 'main' into feat/removal-msg
aljo242 Sep 24, 2024
a66e198
Update x/marketmap/types/msg.go
aljo242 Sep 24, 2024
c5eb8af
Merge branch 'main' into feat/removal-msg
aljo242 Sep 26, 2024
918260f
create simple delete wrapper that is idempotent
aljo242 Sep 27, 2024
6a53f07
hooks
aljo242 Sep 27, 2024
ec18f6d
test
aljo242 Sep 27, 2024
feaf670
fix test
aljo242 Sep 27, 2024
41813ad
proto-gen-new
aljo242 Sep 27, 2024
7e38f75
track deleted markets
aljo242 Sep 27, 2024
1c57735
tested
aljo242 Sep 27, 2024
f87466e
e2e
aljo242 Sep 27, 2024
439f28d
nice
aljo242 Sep 27, 2024
69bed9f
add helper set method
aljo242 Sep 27, 2024
846cd22
clean
aljo242 Sep 27, 2024
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
1,281 changes: 1,218 additions & 63 deletions api/connect/marketmap/v2/tx.pulsar.go

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions api/connect/marketmap/v2/tx_grpc.pb.go

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

25 changes: 25 additions & 0 deletions proto/connect/marketmap/v2/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ service Msg {
// Specifically if a market does not exist it will be created, otherwise it
// will be updated. The response will be a map between ticker -> updated.
rpc UpsertMarkets(MsgUpsertMarkets) returns (MsgUpsertMarketsResponse);

// RemoveMarkets removes the given markets from the marketmap if:
// - they exist in the map
// - they are disabled
rpc RemoveMarkets(MsgRemoveMarkets) returns (MsgRemoveMarketsResponse);
}

// MsgUpsertMarkets defines a message carrying a payload for performing market
Expand Down Expand Up @@ -134,3 +139,23 @@ message MsgRemoveMarketAuthorities {
// MsgRemoveMarketAuthoritiesResponse defines the
// Msg/RemoveMarketAuthoritiesResponse response type.
message MsgRemoveMarketAuthoritiesResponse {}

// MsgRemoveMarkets defines the Msg/RemoveMarkets request type. It contains the
// new markets to be removed from the market map.
message MsgRemoveMarkets {
option (cosmos.msg.v1.signer) = "admin";

// Admin defines the authority that is the x/marketmap
// Admin account. This account is set in the module parameters.
string admin = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// Markets is the list of markets to remove.
repeated string markets = 2;
}

// MsgRemoveMarketsResponse defines the
// Msg/MsgRemoveMarketsResponse response type.
message MsgRemoveMarketsResponse {
// DeletedMarkets is the list of markets that were removed.
repeated string deleted_markets = 1;
}
2 changes: 1 addition & 1 deletion tests/integration/connect_ccv_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func NewConnectCCVIntegrationSuite(
func (s *ConnectCCVSuite) TestCCVAggregation() {
ethusdc := connecttypes.NewCurrencyPair("ETH", "USDC")

s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 3600, ethusdc))
s.Require().NoError(s.AddCurrencyPairs(s.chain, s.user, 3600, enabledTicker(ethusdc)))

cc, closeFn, err := GetChainGRPC(s.chain)
s.Require().NoError(err)
Expand Down
84 changes: 69 additions & 15 deletions tests/integration/connect_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,33 @@ func QueryCurrencyPair(chain *cosmos.CosmosChain, cp connecttypes.CurrencyPair,
return res.Price, int64(res.Nonce), nil
}

// QueryMarket queries a market from the market map.
func QueryMarket(chain *cosmos.CosmosChain, cp connecttypes.CurrencyPair) (mmtypes.Market, error) {
grpcAddr := chain.GetHostGRPCAddress()

// create the client
cc, err := grpc.Dial(grpcAddr, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return mmtypes.Market{}, err
}
defer cc.Close()

// create the mm client
client := mmtypes.NewQueryClient(cc)

ctx := context.Background()

// query the currency pairs
res, err := client.Market(ctx, &mmtypes.MarketRequest{
CurrencyPair: cp,
})
if err != nil {
return mmtypes.Market{}, err
}

return res.Market, nil
}

// SubmitProposal creates and submits a proposal to the chain
func SubmitProposal(chain *cosmos.CosmosChain, deposit sdk.Coin, submitter string, msgs ...sdk.Msg) (string, error) {
// build the proposal
Expand Down Expand Up @@ -359,30 +386,26 @@ func PassProposal(chain *cosmos.CosmosChain, propId string, timeout time.Duratio

// AddCurrencyPairs creates + submits the proposal to add the given currency-pairs to state, votes for the prop w/ all nodes,
// and waits for the proposal to pass.
func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, user cosmos.User, price float64, cps ...connecttypes.CurrencyPair) error {
creates := make([]mmtypes.Market, len(cps))
for i, cp := range cps {
func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, user cosmos.User, price float64,
tickers ...mmtypes.Ticker,
) error {
creates := make([]mmtypes.Market, len(tickers))
for i, ticker := range tickers {
creates[i] = mmtypes.Market{
Ticker: mmtypes.Ticker{
CurrencyPair: cp,
Decimals: 8,
MinProviderCount: 1,
Metadata_JSON: "",
Enabled: true,
},
Ticker: ticker,
ProviderConfigs: []mmtypes.ProviderConfig{
{
Name: static.Name,
OffChainTicker: cp.String(),
OffChainTicker: ticker.String(),
Metadata_JSON: fmt.Sprintf(`{"price": %f}`, price),
},
},
}
}

msg := &mmtypes.MsgCreateMarkets{
Authority: s.user.FormattedAddress(),
CreateMarkets: creates,
msg := &mmtypes.MsgUpsertMarkets{
Authority: s.user.FormattedAddress(),
Markets: creates,
}

tx := CreateTx(s.T(), s.chain, user, gasPrice, msg)
Expand All @@ -403,6 +426,37 @@ func (s *ConnectIntegrationSuite) AddCurrencyPairs(chain *cosmos.CosmosChain, us
return nil
}

func (s *ConnectIntegrationSuite) RemoveMarket(
chain *cosmos.CosmosChain,
markets []connecttypes.CurrencyPair,
) error {
marketString := make([]string, len(markets))
for i, market := range markets {
marketString[i] = market.String()
}

msg := &mmtypes.MsgRemoveMarkets{
Admin: s.user.FormattedAddress(),
Markets: marketString,
}

tx := CreateTx(s.T(), s.chain, s.user, gasPrice, msg)

// get an rpc endpoint for the chain
client := chain.Nodes()[0].Client
// broadcast the tx
resp, err := client.BroadcastTxCommit(context.Background(), tx)
if err != nil {
return err
}

if resp.TxResult.Code != abcitypes.CodeTypeOK {
return fmt.Errorf(resp.TxResult.Log)
}

return nil
}

func (s *ConnectIntegrationSuite) UpdateCurrencyPair(chain *cosmos.CosmosChain, markets []mmtypes.Market) error {
msg := &mmtypes.MsgUpsertMarkets{
Authority: s.user.FormattedAddress(),
Expand Down Expand Up @@ -451,7 +505,7 @@ func QueryProposal(chain *cosmos.CosmosChain, propID string) (*govtypesv1.QueryP
})
}

// WaitForProposalStatus, waits for the deposit period for the proposal to end
// WaitForProposalStatus waits for the deposit period for the proposal to end
func WaitForProposalStatus(chain *cosmos.CosmosChain, propID string, timeout time.Duration, status govtypesv1.ProposalStatus) error {
return testutil.WaitForCondition(timeout, 1*time.Second, func() (bool, error) {
prop, err := QueryProposal(chain, propID)
Expand Down
Loading
Loading