cosmos / interchain-security

Interchain Security is an open sourced IBC application which allows cosmos blockchains to lease their proof-of-stake security to one another.
https://cosmos.github.io/interchain-security/
Other
154 stars 116 forks source link

Most of api of rest are not available #474

Closed liangping closed 1 year ago

liangping commented 1 year ago

Problem

I am setting up rest server for GoC.

you can visit here. https://apollo.api.ping.pub/swagger/

Actually, there are listed in swagger, but it's return unimplement when you call it.

for example:

curl -X 'GET' \
  'https://apollo.api.ping.pub/cosmos/staking/v1beta1/validators' \
  -H 'accept: application/json'

returns:

{
  "code": 12,
  "message": "Not Implemented",
  "details": []
}

version:

./apollo version --long
name: ""
server_name: <appd>
version: ""
commit: ""
build_tags: ""
go: go version go1.18.5 linux/amd64
build_deps:
- filippo.io/edwards25519@v1.0.0-beta.2
- github.com/99designs/keyring@v1.1.6 => github.com/cosmos/keyring@v1.1.7-0.20210622111912-ef00f8ac3d76
- github.com/ChainSafe/go-schnorrkel@v0.0.0-20200405005733-88cbf1b4c40d
- github.com/Workiva/go-datastructures@v1.0.53
- github.com/armon/go-metrics@v0.3.10
- github.com/beorn7/perks@v1.0.1
- github.com/bgentry/speakeasy@v0.1.0
- github.com/btcsuite/btcd@v0.22.0-beta
- github.com/cespare/xxhash/v2@v2.1.2
- github.com/coinbase/rosetta-sdk-go@v0.7.0
- github.com/confio/ics23/go@v0.7.0
- github.com/cosmos/btcutil@v1.0.4
- github.com/cosmos/cosmos-sdk@v0.45.7-0.20221104161803-456ca5663c5e
- github.com/cosmos/go-bip39@v1.0.0
- github.com/cosmos/iavl@v0.17.3
- github.com/cosmos/ibc-go/v3@v3.0.0-alpha1.0.20220210141024-fb2f0416254b => github.com/informalsystems/ibc-go/v3@v3.0.0-beta1.0.20220816140824-aba9c2f2b943
- github.com/davecgh/go-spew@v1.1.1
- github.com/desertbit/timer@v0.0.0-20180107155436-c41aec40b27f
- github.com/dvsekhvalnov/jose2go@v0.0.0-20200901110807-248326c1351b
- github.com/felixge/httpsnoop@v1.0.1
- github.com/fsnotify/fsnotify@v1.5.1
- github.com/go-kit/kit@v0.12.0
- github.com/go-kit/log@v0.2.0
- github.com/go-logfmt/logfmt@v0.5.1
- github.com/godbus/dbus@v0.0.0-20190726142602-4481cbc300e2
- github.com/gogo/gateway@v1.1.0
- github.com/gogo/protobuf@v1.3.3 => github.com/regen-network/protobuf@v1.3.3-alpha.regen.1
- github.com/golang/protobuf@v1.5.2
- github.com/golang/snappy@v0.0.3
- github.com/google/btree@v1.0.0
- github.com/google/orderedcode@v0.0.1
- github.com/gorilla/handlers@v1.5.1
- github.com/gorilla/mux@v1.8.0
- github.com/gorilla/websocket@v1.5.0
- github.com/grpc-ecosystem/go-grpc-middleware@v1.3.0
- github.com/grpc-ecosystem/grpc-gateway@v1.16.0
- github.com/gsterjov/go-libsecret@v0.0.0-20161001094733-a6f4afe4910c
- github.com/gtank/merlin@v0.1.1
- github.com/gtank/ristretto255@v0.1.2
- github.com/hashicorp/go-immutable-radix@v1.3.1
- github.com/hashicorp/golang-lru@v0.5.4
- github.com/hashicorp/hcl@v1.0.0
- github.com/hdevalence/ed25519consensus@v0.0.0-20210204194344-59a8610d2b87
- github.com/improbable-eng/grpc-web@v0.14.1
- github.com/klauspost/compress@v1.13.6
- github.com/lib/pq@v1.10.4
- github.com/libp2p/go-buffer-pool@v0.0.2
- github.com/magiconair/properties@v1.8.5
- github.com/mattn/go-isatty@v0.0.14
- github.com/matttproud/golang_protobuf_extensions@v1.0.1
- github.com/mimoo/StrobeGo@v0.0.0-20181016162300-f8f6d4d2b643
- github.com/minio/highwayhash@v1.0.2
- github.com/mitchellh/mapstructure@v1.4.3
- github.com/mtibben/percent@v0.2.1
- github.com/pelletier/go-toml@v1.9.4
- github.com/pkg/errors@v0.9.1
- github.com/pmezard/go-difflib@v1.0.0
- github.com/prometheus/client_golang@v1.12.1
- github.com/prometheus/client_model@v0.2.0
- github.com/prometheus/common@v0.32.1
- github.com/prometheus/procfs@v0.7.3
- github.com/rakyll/statik@v0.1.7
- github.com/rcrowley/go-metrics@v0.0.0-20200313005456-10cdbea86bc0
- github.com/regen-network/cosmos-proto@v0.3.1
- github.com/rs/cors@v1.8.2
- github.com/rs/zerolog@v1.25.0
- github.com/spf13/afero@v1.6.0
- github.com/spf13/cast@v1.4.1
- github.com/spf13/cobra@v1.4.0
- github.com/spf13/jwalterweatherman@v1.1.0
- github.com/spf13/pflag@v1.0.5
- github.com/spf13/viper@v1.10.1
- github.com/stretchr/testify@v1.7.1
- github.com/subosito/gotenv@v1.2.0
- github.com/syndtr/goleveldb@v1.0.1-0.20200815110645-5c35d600f0ca
- github.com/tendermint/btcd@v0.1.1
- github.com/tendermint/crypto@v0.0.0-20191022145703-50d29ede1e15
- github.com/tendermint/go-amino@v0.16.0
- github.com/tendermint/spm@v0.1.9
- github.com/tendermint/tendermint@v0.34.19
- github.com/tendermint/tm-db@v0.6.6
- golang.org/x/crypto@v0.0.0-20210921155107-089bfa567519
- golang.org/x/net@v0.0.0-20220225172249-27dd8689420f
- golang.org/x/sys@v0.0.0-20220315194320-039c03cc5b86
- golang.org/x/term@v0.0.0-20210927222741-03fcf44c2211
- golang.org/x/text@v0.3.7
- google.golang.org/genproto@v0.0.0-20220519153652-3a47de7e79bd
- google.golang.org/grpc@v1.46.2 => google.golang.org/grpc@v1.33.2
- google.golang.org/protobuf@v1.28.0
- gopkg.in/ini.v1@v1.66.2
- gopkg.in/yaml.v2@v2.4.0
- gopkg.in/yaml.v3@v3.0.0-20210107192922-496545a6307b
- nhooyr.io/websocket@v1.8.6
cosmos_sdk_version: v0.45.7-0.20221104161803-456ca5663c5e

Closing criteria

TODOs

danwt commented 1 year ago

Thanks for raising this!

MSalopek commented 1 year ago

Hello!

Can you share the command you are using to start the node?

Interchain-secured chains (aka consumer chains) do not require or use the staking module since they are secured by the stake of the provider chain, so the endpoint /cosmos/staking/v1beta1/validators is indeed unimplemented.

Consumer chains have the same validator set as their respective provider chain.

If you need validator info, you can check tendermint endpoints:

These are not as pretty as you might need since they don't show validator info such as moniker, contacts etc. only their consensus address and pubkey.

{
  "jsonrpc": "2.0",
  "id": -1,
  "result": {
    "block_height": "100562",
    "validators": [
      {
        "address": "6A3CACEAEA586C9AF3051249D6FF34942835DF10",
        "pub_key": {
          "type": "tendermint/PubKeyEd25519",
          "value": "QVGxt7g4K/NWFw/8Zr3UX4M53l28bHq/aOhDNAD6NJo="
        },
        "voting_power": "670100004",
        "proposer_priority": "-169193046"
      }
   ]
}
liangping commented 1 year ago

Hey, @MSalopek , thanks for feedback.

Can you share the command you are using to start the node?

we simply run apollod start.

the above staking endpoint is an example of most of them.

https://apollo-rpc.ztake.org/validators?height=100562&page=1&per_page=100 returns too few infomation, and not readable for normal users.

For many front-end tools like Ping Dashboard, It heavily depend on the endpoint implementation.
Is it possible to remove the endpoints from swagger if we didn't implement. and add the new ones.

If consumer chain don't have the most endpoint, I need to figure out a way for consumer chain. do you have any suggestion?

liangping commented 1 year ago

@MSalopek , I got an idea.

Can I just fetch staking related data from provider staking endpoints.

it should be ok, if consumer chains are as exactly same as the provider.

I found that staking, distribution, gov module have been removed on consumer chains.

MSalopek commented 1 year ago

@liangping

Can I just fetch staking related data from provider staking endpoints.

This should be safe to do. Infractions on any of the consumer chains will cause slashing/jaling/tombstoning on the provider. Likewise, an infraction on the provider chain will be reflected in all consumer chain validator sets.

The consumer chain does not store all metadata about each validator in the set, only the consensus address, power and pubkey since they are needed for module operation.

// CrossChainValidator defines the validators for CCV consumer module
message CrossChainValidator {
  bytes address = 1;
  int64 power = 2;
  // pubkey is the consensus public key of the validator, as a Protobuf Any.
  google.protobuf.Any pubkey = 3 [
    (cosmos_proto.accepts_interface) = "cosmos.crypto.PubKey",
    (gogoproto.moretags) = "yaml:\"consensus_pubkey\""
  ];
}

Adding a separate query on the consumer would yield a result identical to chaind query tendermint-validator-set query.

I found that staking, distribution, gov module have been removed on consumer chains.

Please bear in mind that this statement is not valid for all consumer chains, only the ones currently running in Game of Chains testnet. A consumer chain may choose to use those modules, as interchain security can be viewed as just another SDK module.

You can check the democracy consumer chain in the ICS codebase - it implements the staking, governance and distribution modules, alongside interchain security - it should have the APIs you mentioned enabled.

liangping commented 1 year ago

Thanks,

MSalopek commented 1 year ago

Closing for now. Will repoen if anything new emerges.