synapsecns / sanguine

Synapse Monorepo
MIT License
38 stars 29 forks source link

(OmniRPC missing harmony chainid) #244

Open trajan0x opened 2 years ago

trajan0x commented 2 years ago
curl 'https://scribe.interoperability.institute/confirmations/5/rpc/1666600000' \
  -H 'authority: scribe.interoperability.institute' \
  -H 'accept: */*' \
  -H 'accept-language: en-US,en;q=0.9,eu;q=0.8,af;q=0.7,ar;q=0.6,hy;q=0.5,bn;q=0.4,la;q=0.3,zh-CN;q=0.2,zh-TW;q=0.1,zh;q=0.1,he;q=0.1' \
  -H 'cache-control: no-cache' \
  -H 'content-type: application/json' \
  -H 'origin: chrome-extension://nkbihfbeogaeaoehlefnkodbefgpgknn' \
  -H 'pragma: no-cache' \
  -H 'sec-ch-ua: "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'sec-ch-ua-platform: "macOS"' \
  -H 'sec-fetch-dest: empty' \
  -H 'sec-fetch-mode: cors' \
  -H 'sec-fetch-site: none' \
  -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36' \
  --data-raw '{"id":"1665190841281","jsonrpc":"2.0","method":"eth_chainId","params":[]}' \
  --compressed
trajan0x commented 1 year ago

Some real tests around chains we're on would be cool as well, not quite sure what this looks like yet

trajan0x commented 6 months ago

Should attempt to address in #1735

greptile-apps[bot] commented 3 months ago

To resolve the issue of the missing Harmony chain ID (1666600000) in OmniRPC, follow these steps:

  1. Update Configuration: Add the Harmony chain ID to the configuration file.

    // services/omnirpc/config/config.go
    type Config struct {
       Chains map[uint32]ChainConfig `yaml:"chains"`
       // ... other fields
    }
    
    // Add Harmony chain ID to the default configuration
    func GetPublicRPCConfig() (Config, error) {
       return Config{
           Chains: map[uint32]ChainConfig{
               1666600000: {
                   RPCs: []string{
                       "https://api.harmony.one",
                       "https://s1.api.harmony.one",
                       "https://s2.api.harmony.one",
                       "https://s3.api.harmony.one",
                   },
                   Checks: 1,
               },
               // ... other chains
           },
           // ... other fields
       }, nil
    }
  2. Update Command: Ensure the command that uses the configuration can handle the new chain ID.

    // services/omnirpc/cmd/commands.go
    var latencyCommand = &cli.Command{
       Name:  "check-latency",
       Usage: "checks latency for all rpc endpoints known for a chain id",
       Flags: []cli.Flag{chainIDFlag},
       Action: func(c *cli.Context) error {
           rConfig, err := rpcConfig.GetPublicRPCConfig()
           if err != nil {
               return fmt.Errorf("could not get rpc map: %w", err)
           }
    
           chainConfig, ok := rConfig.Chains[uint32(c.Int(chainIDFlag.Name))]
           if !ok {
               return fmt.Errorf("could not get chain config for chain %d", c.Int(chainIDFlag.Name))
           }
    
           res := rpcinfo.GetRPCLatency(c.Context, time.Second*5, chainConfig.RPCs, metrics.Get())
           DisplayLatency(res)
    
           return nil
       },
    }

This will add support for the Harmony chain ID in the OmniRPC configuration and ensure that the commands can handle it.

References

/services/omnirpc/cmd/commands.go /services/omnirpc/config/config.go /services/omnirpc/config/config_test.go /services/omnirpc /services/omnirpc/proxy /services/omnirpc/chainmanager/mocks

Ask Greptile