Open trajan0x opened 2 years ago
Some real tests around chains we're on would be cool as well, not quite sure what this looks like yet
Should attempt to address in #1735
To resolve the issue of the missing Harmony chain ID (1666600000) in OmniRPC, follow these steps:
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
}
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.
/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