Skip to content

Commit

Permalink
Remove wsrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
samsondav committed Feb 11, 2025
1 parent 397c29d commit becd1db
Show file tree
Hide file tree
Showing 54 changed files with 44 additions and 3,171 deletions.
4 changes: 4 additions & 0 deletions .changeset/moody-swans-worry.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@
---

Remove support for mercury #removed

Remove support for wsrpc protocol for LLO

Remove `Mercury.Cache` configuration options
10 changes: 0 additions & 10 deletions core/cmd/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/keystore"
"github.com/smartcontractkit/chainlink/v2/core/services/llo"
"github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/cache"
"github.com/smartcontractkit/chainlink/v2/core/services/versioning"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
"github.com/smartcontractkit/chainlink/v2/core/services/workflows"
Expand Down Expand Up @@ -231,12 +229,6 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G

loopRegistry := plugins.NewLoopRegistry(appLggr, cfg.Database(), cfg.Tracing(), cfg.Telemetry(), beholderAuthHeaders, csaPubKeyHex)

mercuryPool := wsrpc.NewPool(appLggr, cache.Config{
LatestReportTTL: cfg.Mercury().Cache().LatestReportTTL(),
MaxStaleAge: cfg.Mercury().Cache().MaxStaleAge(),
LatestReportDeadline: cfg.Mercury().Cache().LatestReportDeadline(),
})

capabilitiesRegistry := capabilities.NewRegistry(appLggr)

retirementReportCache := llo.NewRetirementReportCache(appLggr, ds)
Expand All @@ -249,7 +241,6 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G
Registerer: appRegisterer,
LoopRegistry: loopRegistry,
GRPCOpts: grpcOpts,
MercuryPool: mercuryPool,
CapabilitiesRegistry: capabilitiesRegistry,
HTTPClient: unrestrictedClient,
RetirementReportCache: retirementReportCache,
Expand Down Expand Up @@ -320,7 +311,6 @@ func (n ChainlinkAppFactory) NewApplication(ctx context.Context, cfg chainlink.G
SecretGenerator: chainlink.FilePersistedSecretGenerator{},
LoopRegistry: loopRegistry,
GRPCOpts: grpcOpts,
MercuryPool: mercuryPool,
RetirementReportCache: retirementReportCache,
LLOTransmissionReaper: lloReaper,
CapabilitiesRegistry: capabilitiesRegistry,
Expand Down
26 changes: 2 additions & 24 deletions core/config/docs/core.toml
Original file line number Diff line number Diff line change
Expand Up @@ -676,27 +676,6 @@ env = 'test' # Example
# by default.
VerboseLogging = false # Default

# Mercury.Cache controls settings for the price retrieval cache querying a mercury server
[Mercury.Cache]
# LatestReportTTL controls how "stale" we will allow a price to be e.g. if
# set to 1s, a new price will always be fetched if the last result was
# from 1 second ago or older.
#
# Another way of looking at it is such: the cache will _never_ return a
# price that was queried from now-LatestReportTTL or before.
#
# Setting to zero disables caching entirely.
LatestReportTTL = "1s" # Default
# MaxStaleAge is that maximum amount of time that a value can be stale
# before it is deleted from the cache (a form of garbage collection).
#
# This should generally be set to something much larger than
# LatestReportTTL. Setting to zero disables garbage collection.
MaxStaleAge = "1h" # Default
# LatestReportDeadline controls how long to wait for a response from the
# mercury server before retrying. Setting this to zero will wait indefinitely.
LatestReportDeadline = "5s" # Default

# Mercury.TLS controls client settings for when the node talks to traditional web servers or load balancers.
[Mercury.TLS]
# CertFile is the path to a PEM file of trusted root certificate authority certificates
Expand All @@ -706,10 +685,9 @@ CertFile = "/path/to/client/certs.pem" # Example
[Mercury.Transmitter]
# Protocol is the protocol to use for the transmitter.
#
# Options are either:
# - "wsrpc" for the legacy websocket protocol
# Options are currently:
# - "grpc" for the gRPC protocol
Protocol = "wsrpc" # Default
Protocol = "grpc" # Default
# TransmitQueueMaxSize controls the size of the transmit queue. This is scoped
# per OCR instance. If the queue is full, the transmitter will start dropping
# the oldest messages in order to make space.
Expand Down
13 changes: 1 addition & 12 deletions core/config/mercury_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@ package config

import (
"fmt"
"time"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/types"
)

type MercuryCache interface {
LatestReportTTL() time.Duration
MaxStaleAge() time.Duration
LatestReportDeadline() time.Duration
}

type MercuryTLS interface {
CertFile() string
}

type MercuryTransmitterProtocol string

const (
MercuryTransmitterProtocolWSRPC MercuryTransmitterProtocol = "wsrpc"
MercuryTransmitterProtocolGRPC MercuryTransmitterProtocol = "grpc"
MercuryTransmitterProtocolGRPC MercuryTransmitterProtocol = "grpc"
)

func (m MercuryTransmitterProtocol) String() string {
Expand All @@ -31,8 +23,6 @@ func (m MercuryTransmitterProtocol) String() string {

func (m *MercuryTransmitterProtocol) UnmarshalText(text []byte) error {
switch string(text) {
case "wsrpc":
*m = MercuryTransmitterProtocolWSRPC
case "grpc":
*m = MercuryTransmitterProtocolGRPC
default:
Expand All @@ -52,7 +42,6 @@ type MercuryTransmitter interface {

type Mercury interface {
Credentials(credName string) *types.MercuryCredentials
Cache() MercuryCache
TLS() MercuryTLS
Transmitter() MercuryTransmitter
VerboseLogging() bool
Expand Down
20 changes: 0 additions & 20 deletions core/config/toml/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,24 +1291,6 @@ func (ins *Insecure) setFrom(f *Insecure) {
}
}

type MercuryCache struct {
LatestReportTTL *commonconfig.Duration
MaxStaleAge *commonconfig.Duration
LatestReportDeadline *commonconfig.Duration
}

func (mc *MercuryCache) setFrom(f *MercuryCache) {
if v := f.LatestReportTTL; v != nil {
mc.LatestReportTTL = v
}
if v := f.MaxStaleAge; v != nil {
mc.MaxStaleAge = v
}
if v := f.LatestReportDeadline; v != nil {
mc.LatestReportDeadline = v
}
}

type MercuryTLS struct {
CertFile *string
}
Expand Down Expand Up @@ -1359,14 +1341,12 @@ func (m *MercuryTransmitter) setFrom(f *MercuryTransmitter) {
}

type Mercury struct {
Cache MercuryCache `toml:",omitempty"`
TLS MercuryTLS `toml:",omitempty"`
Transmitter MercuryTransmitter `toml:",omitempty"`
VerboseLogging *bool `toml:",omitempty"`
}

func (m *Mercury) setFrom(f *Mercury) {
m.Cache.setFrom(&f.Cache)
m.TLS.setFrom(&f.TLS)
m.Transmitter.setFrom(&f.Transmitter)
if v := f.VerboseLogging; v != nil {
Expand Down
10 changes: 0 additions & 10 deletions core/internal/cltest/cltest.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ import (
p2ptypes "github.com/smartcontractkit/chainlink/v2/core/services/p2p/types"
"github.com/smartcontractkit/chainlink/v2/core/services/pg"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc/cache"
"github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities"
"github.com/smartcontractkit/chainlink/v2/core/services/webhook"
clsessions "github.com/smartcontractkit/chainlink/v2/core/sessions"
Expand Down Expand Up @@ -415,20 +413,13 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
mailMon := mailbox.NewMonitor(cfg.AppID().String(), lggr.Named("Mailbox"))
loopRegistry := plugins.NewLoopRegistry(lggr, cfg.Database(), cfg.Tracing(), cfg.Telemetry(), nil, "")

mercuryPool := wsrpc.NewPool(lggr, cache.Config{
LatestReportTTL: cfg.Mercury().Cache().LatestReportTTL(),
MaxStaleAge: cfg.Mercury().Cache().MaxStaleAge(),
LatestReportDeadline: cfg.Mercury().Cache().LatestReportDeadline(),
})

c := clhttptest.NewTestLocalOnlyHTTPClient()
retirementReportCache := llo.NewRetirementReportCache(lggr, ds)
relayerFactory := chainlink.RelayerFactory{
Logger: lggr,
LoopRegistry: loopRegistry,
GRPCOpts: loop.GRPCOpts{},
Registerer: prometheus.NewRegistry(), // Don't use global registry here since otherwise multiple apps can create name conflicts. Could also potentially give a mock registry to test prometheus.
MercuryPool: mercuryPool,
CapabilitiesRegistry: capabilitiesRegistry,
HTTPClient: c,
RetirementReportCache: retirementReportCache,
Expand Down Expand Up @@ -502,7 +493,6 @@ func NewApplicationWithConfig(t testing.TB, cfg chainlink.GeneralConfig, flagsAn
UnrestrictedHTTPClient: c,
SecretGenerator: MockSecretGenerator{},
LoopRegistry: plugins.NewTestLoopRegistry(lggr),
MercuryPool: mercuryPool,
CapabilitiesRegistry: capabilitiesRegistry,
CapabilitiesDispatcher: dispatcher,
CapabilitiesPeerWrapper: peerWrapper,
Expand Down
7 changes: 1 addition & 6 deletions core/services/chainlink/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/periodicbackup"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
"github.com/smartcontractkit/chainlink/v2/core/services/registrysyncer"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/core/services/standardcapabilities"
"github.com/smartcontractkit/chainlink/v2/core/services/streams"
"github.com/smartcontractkit/chainlink/v2/core/services/telemetry"
Expand Down Expand Up @@ -190,7 +189,6 @@ type ApplicationOpts struct {
SecretGenerator SecretGenerator
LoopRegistry *plugins.LoopRegistry
GRPCOpts loop.GRPCOpts
MercuryPool wsrpc.Pool
RetirementReportCache llo.RetirementReportCache
LLOTransmissionReaper services.ServiceCtx
CapabilitiesRegistry *capabilities.Registry
Expand Down Expand Up @@ -486,10 +484,7 @@ func NewApplication(opts ApplicationOpts) (Application, error) {
globalLogger.Info("DatabaseBackup: periodic database backups are disabled. To enable automatic backups, set Database.Backup.Mode=lite or Database.Backup.Mode=full")
}

// pool must be started before all relayers and stopped after them
if opts.MercuryPool != nil {
srvcs = append(srvcs, opts.MercuryPool)
}
// LLO-related services
if opts.RetirementReportCache != nil {
srvcs = append(srvcs, opts.RetirementReportCache)
}
Expand Down
22 changes: 0 additions & 22 deletions core/services/chainlink/config_mercury.go
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
package chainlink

import (
"time"

commonconfig "github.com/smartcontractkit/chainlink-common/pkg/config"
"github.com/smartcontractkit/chainlink-common/pkg/types"

"github.com/smartcontractkit/chainlink/v2/core/config"
"github.com/smartcontractkit/chainlink/v2/core/config/toml"
)

var _ config.MercuryCache = (*mercuryCacheConfig)(nil)

type mercuryCacheConfig struct {
c toml.MercuryCache
}

func (m *mercuryCacheConfig) LatestReportTTL() time.Duration {
return m.c.LatestReportTTL.Duration()
}
func (m *mercuryCacheConfig) MaxStaleAge() time.Duration {
return m.c.MaxStaleAge.Duration()
}
func (m *mercuryCacheConfig) LatestReportDeadline() time.Duration {
return m.c.LatestReportDeadline.Duration()
}

var _ config.MercuryTLS = (*mercuryTLSConfig)(nil)

type mercuryTLSConfig struct {
Expand Down Expand Up @@ -86,10 +68,6 @@ func (m *mercuryConfig) Credentials(credName string) *types.MercuryCredentials {
return nil
}

func (m *mercuryConfig) Cache() config.MercuryCache {
return &mercuryCacheConfig{c: m.c.Cache}
}

func (m *mercuryConfig) TLS() config.MercuryTLS {
return &mercuryTLSConfig{c: m.c.TLS}
}
Expand Down
10 changes: 0 additions & 10 deletions core/services/chainlink/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -776,11 +776,6 @@ func TestConfig_Marshal(t *testing.T) {
},
}
full.Mercury = toml.Mercury{
Cache: toml.MercuryCache{
LatestReportTTL: commoncfg.MustNewDuration(100 * time.Second),
MaxStaleAge: commoncfg.MustNewDuration(101 * time.Second),
LatestReportDeadline: commoncfg.MustNewDuration(102 * time.Second),
},
TLS: toml.MercuryTLS{
CertFile: ptr("/path/to/cert.pem"),
},
Expand Down Expand Up @@ -1255,11 +1250,6 @@ SendOnly = true
{"Mercury", Config{Core: toml.Core{Mercury: full.Mercury}}, `[Mercury]
VerboseLogging = true
[Mercury.Cache]
LatestReportTTL = '1m40s'
MaxStaleAge = '1m41s'
LatestReportDeadline = '1m42s'
[Mercury.TLS]
CertFile = '/path/to/cert.pem'
Expand Down
3 changes: 0 additions & 3 deletions core/services/chainlink/relayer_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/relay"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/dummy"
evmrelay "github.com/smartcontractkit/chainlink/v2/core/services/relay/evm"
"github.com/smartcontractkit/chainlink/v2/core/services/relay/evm/mercury/wsrpc"
"github.com/smartcontractkit/chainlink/v2/plugins"
)

Expand All @@ -34,7 +33,6 @@ type RelayerFactory struct {
*plugins.LoopRegistry
loop.GRPCOpts
Registerer prometheus.Registerer
MercuryPool wsrpc.Pool
CapabilitiesRegistry coretypes.CapabilitiesRegistry
HTTPClient *http.Client
RetirementReportCache llo.RetirementReportCache
Expand Down Expand Up @@ -80,7 +78,6 @@ func (r *RelayerFactory) NewEVM(ctx context.Context, config EVMFactoryConfig) (m
DS: ccOpts.DS,
Registerer: r.Registerer,
CSAETHKeystore: config.CSAETHKeystore,
MercuryPool: r.MercuryPool,
MercuryConfig: config.MercuryConfig,
CapabilitiesRegistry: r.CapabilitiesRegistry,
HTTPClient: r.HTTPClient,
Expand Down
7 changes: 1 addition & 6 deletions core/services/chainlink/testdata/config-empty-effective.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,11 @@ TLSCertPath = ''
[Mercury]
VerboseLogging = false

[Mercury.Cache]
LatestReportTTL = '1s'
MaxStaleAge = '1h0m0s'
LatestReportDeadline = '5s'

[Mercury.TLS]
CertFile = ''

[Mercury.Transmitter]
Protocol = 'wsrpc'
Protocol = 'grpc'
TransmitQueueMaxSize = 100000
TransmitTimeout = '5s'
TransmitConcurrency = 100
Expand Down
5 changes: 0 additions & 5 deletions core/services/chainlink/testdata/config-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ test = 'load'
[Mercury]
VerboseLogging = true

[Mercury.Cache]
LatestReportTTL = '1m40s'
MaxStaleAge = '1m41s'
LatestReportDeadline = '1m42s'

[Mercury.TLS]
CertFile = '/path/to/cert.pem'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,11 @@ TLSCertPath = ''
[Mercury]
VerboseLogging = false

[Mercury.Cache]
LatestReportTTL = '1s'
MaxStaleAge = '1h0m0s'
LatestReportDeadline = '5s'

[Mercury.TLS]
CertFile = ''

[Mercury.Transmitter]
Protocol = 'wsrpc'
Protocol = 'grpc'
TransmitQueueMaxSize = 100000
TransmitTimeout = '5s'
TransmitConcurrency = 100
Expand Down
1 change: 0 additions & 1 deletion core/services/ocr2/delegate.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ type jobPipelineConfig interface {

type mercuryConfig interface {
Credentials(credName string) *types.MercuryCredentials
Cache() coreconfig.MercuryCache
TLS() coreconfig.MercuryTLS
Transmitter() coreconfig.MercuryTransmitter
VerboseLogging() bool
Expand Down
Loading

0 comments on commit becd1db

Please sign in to comment.