-
Notifications
You must be signed in to change notification settings - Fork 1
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
Create MultiNode Adaptor #7
base: main
Are you sure you want to change the base?
Conversation
988f9b2
to
cfbc9d2
Compare
…tcontractkit/chainlink-framework into BCFR-1071-multinode-adaptor
} | ||
|
||
// Adapter is used to integrate multinode into chain-specific clients | ||
type Adapter[RPC any, HEAD Head] struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice also to provide a standardized method for measuring latency (including prom metrics)
// chStopInFlight can be closed to immediately cancel all in-flight requests on | ||
// this RpcMultiNodeAdapter. Closing and replacing should be serialized through | ||
// stateMu since it can happen on state transitions as well as RpcMultiNodeAdapter Close. | ||
chStopInFlight chan struct{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we rename this to a lifeCycleCh to signal that it's closed once RPC is declared unhealthy?
|
||
// GetChStopInflight provides a convenience helper that mutex wraps a | ||
// read to the chStopInFlight | ||
func (m *Adapter[RPC, HEAD]) GetChStopInflight() chan struct{} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need all GetChStopInflight, MakeQueryCtx and AcquireQueryCtx methods?
return m.chStopInFlight | ||
} | ||
|
||
func (m *Adapter[RPC, HEAD]) ResetLatestChainInfo() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this public?
} | ||
|
||
func (m *Adapter[RPC, HEAD]) GetInterceptedChainInfo() (latest, highestUserObservations ChainInfo) { | ||
m.chainInfoLock.Lock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be RLock?
c := newTestClient(t) | ||
head, err := c.LatestBlock(tests.Context(t)) | ||
require.NoError(t, err) | ||
require.True(t, head.IsValid()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also test that chain info is updated
return c | ||
} | ||
|
||
func TestMultiNodeClient_LatestBlock(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It woulbe be nice to add more coverage to verify that OnNewHead and OnNewFinalizedHead properly treats HealthCheckRequests and respects closure of requestCh
Description
Ticket: https://smartcontract-it.atlassian.net/browse/BCFR-1071
Most of the code in the Solana MultiNodeClient can be reused by all chain integrations. This PR extracts all of the chain-agnostic client code through making a generic MultiNodeAdaptor. This will further extract functionality into the MultiNode and reduce new integration cost.
Generic MultiNodeAdaptor:
The the following methods can all be chain-agnostic and extracted:
All other client methods will still be implemented on the chain specific side including: