-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Implement new Interfaces for Multinode #13184
base: BCI-3160-EVM-MultiNode-PoC
Are you sure you want to change the base?
Implement new Interfaces for Multinode #13184
Conversation
I see you updated files related to
|
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.
Nice progress!
if err != nil { | ||
return nil, err | ||
} | ||
return rpc.LatestBlockHeight(ctx) | ||
} | ||
|
||
func (c *chainClient) NodeStates() map[string]string { |
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 might be better to change the signature to this method to also use NodeState. Unless it significantly increases scope of the PR
if n.State() != nodeStateAlive { | ||
continue | ||
} | ||
if do(ctx, n.RPC(), false) { |
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 abort DoAll if do returned false
return nil | ||
} | ||
|
||
func (c *multiNode[CHAIN_ID, BLOCK_HASH, HEAD, RPC_CLIENT]) NodeStates() map[string]string { |
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.
Can't we use map[string]NodeState
as a return value?
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.
Yes, plan on changing this after fixing tests
@@ -13,10 +12,10 @@ import ( | |||
|
|||
// RPCClient includes all the necessary generalized RPC methods along with any additional chain-specific methods. | |||
// | |||
//go:generate mockery --quiet --name RPCClient --output ./mocks --case=underscore | |||
//go:generate mockery --quiet --name RPCClient --structname MockRPCClient --filename "mock_rpc_client_test.go" --inpackage --case=underscore |
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 try to avoid public mocks as they cause redundant dependencies between packages.
If someone needs to mock implementation of the RPCClient, they should generate their own
n.declareUnreachable() | ||
return | ||
} | ||
// TODO: nit fix. If multinode switches primary node before we set sub as AliveSub, sub will be closed and we'll | ||
// falsely transition this node to unreachable state | ||
n.rpc.SetAliveLoopSub(sub) | ||
n.aliveLoopSub = sub |
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.
Could you fix this TODO.
We should lock aliveLoopSub on assignment and when unsubscribing
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.
Also it might be good idea to add to common/types.Subscription
doc, that we should be able to call Unsubscribe
multiple times
common/client/node_lifecycle.go
Outdated
@@ -138,42 +139,47 @@ func (n *node[CHAIN_ID, HEAD, RPC]) aliveLoop() { | |||
lggr.Debug("Polling disabled") | |||
} | |||
|
|||
var pollFinalizedHeadCh <-chan time.Time | |||
var finalizedHeadCh <-chan HEAD | |||
var finalizedHeadSub types.Subscription | |||
if n.chainCfg.FinalityTagEnabled() && n.nodePoolCfg.FinalizedBlockPollInterval() > 0 { |
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.
Hm, FinalizedBlockPollInterval
setting is specific to the EVM. We should remove the check here.
The evm's RPC Client should handle it.
If the FinalizedBlockPollInterval=0
RPC Client should log an error and return nil channel
lggr logger.SugaredLogger | ||
selectionMode string | ||
// noNewHeadsThreshold time.Duration TODO: Move this? | ||
nodeSelector NodeSelector[CHAIN_ID, HEAD, RPC_CLIENT] |
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.
After deeper review it seems to be possible to drop Head and BlockHash generic parameters without need to move nodeSelector creation
@@ -30,6 +30,47 @@ import ( | |||
ubig "github.com/smartcontractkit/chainlink/v2/core/chains/evm/utils/big" | |||
) | |||
|
|||
//go:generate mockery --quiet --name EvmRpcClient --structname MockEvmRpcClient --filename "mock_evm_rpc_client_test.go" --inpackage --case=underscore | |||
type EvmRpcClient interface { |
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 try to avoid including parts of package path into type name.
What do you think of renaming this to ChainClientRPC (seems like we only use it there)?
Another option is to rollback change of making RpcClient public and name the interface as RpcClient
…contractkit/chainlink into BCI-3160-implement-node-interface
Quality Gate failedFailed conditions See analysis details on SonarQube Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
Node and Multinode interfaces