Skip to content

Commit e50e1f3

Browse files
committed
Add rpc newHeads method
1 parent 252c488 commit e50e1f3

File tree

7 files changed

+6
-44
lines changed

7 files changed

+6
-44
lines changed

common/client/multi_node.go

-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ func (c *MultiNode[CHAIN_ID, RPC_CLIENT]) HighestChainInfo() ChainInfo {
172172
// Nodes handle their own redialing and runloops, so this function does not
173173
// return any error if the nodes aren't available
174174
func (c *MultiNode[CHAIN_ID, RPC_CLIENT]) Dial(ctx context.Context) error {
175-
fmt.Println("MULTINODE DIAL")
176175
ctx = context.Background() // TODO: remove this line
177176
return c.StartOnce("MultiNode", func() (merr error) {
178177
if len(c.primaryNodes) == 0 {

common/client/node.go

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ func (n *node[CHAIN_ID, HEAD, RPC_CLIENT]) Start(startCtx context.Context) error
244244
// Node lifecycle is synchronous: only one goroutine should be running at a
245245
// time.
246246
func (n *node[CHAIN_ID, HEAD, RPC_CLIENT]) start(startCtx context.Context) {
247-
fmt.Println("NODE START")
248247
startCtx = context.Background() // TODO: remove this line
249248
if n.state != NodeStateUndialed {
250249
panic(fmt.Sprintf("cannot dial node with state %v", n.state))

common/client/node_lifecycle.go

-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,6 @@ const (
7474
msgDegradedState = "Chainlink is now operating in a degraded state and urgent action is required to resolve the issue"
7575
)
7676

77-
// const rpcSubscriptionMethodNewHeads = "newHeads"
78-
7977
// Node is a FSM
8078
// Each state has a loop that goes with it, which monitors the node and moves it into another state as necessary.
8179
// Only one loop must run at a time.

core/chains/evm/client/chain_client.go

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package client
22

33
import (
44
"context"
5-
"fmt"
65
"math/big"
76
"sync"
87
"time"
@@ -259,7 +258,6 @@ func (c *chainClient) ConfiguredChainID() *big.Int {
259258
}
260259

261260
func (c *chainClient) Dial(ctx context.Context) error {
262-
fmt.Println("CHAINCLIENT DIAL") // TODO: REMOVE
263261
return c.multiNode.Dial(ctx)
264262
}
265263

core/chains/evm/client/chain_client_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ func (x *sendTxService) SendRawTransaction(ctx context.Context, signRawTx hexuti
704704
x.sentCount.Add(1)
705705
return nil
706706
}
707+
*/
707708

708709
func TestEthClient_SubscribeNewHead(t *testing.T) {
709710
t.Parallel()
@@ -727,10 +728,12 @@ func TestEthClient_SubscribeNewHead(t *testing.T) {
727728

728729
ethClient := mustNewChainClientWithChainID(t, wsURL, chainId)
729730
err := ethClient.Dial(tests.Context(t))
731+
fmt.Println("DIALLED!!")
730732
require.NoError(t, err)
731733

732734
headCh, sub, err := ethClient.SubscribeNewHead(ctx)
733735
require.NoError(t, err)
736+
fmt.Println("SUBSCRIBED!!")
734737

735738
select {
736739
case err := <-sub.Err():
@@ -743,7 +746,6 @@ func TestEthClient_SubscribeNewHead(t *testing.T) {
743746
}
744747
sub.Unsubscribe()
745748
}
746-
*/
747749

748750
func newMockRpc(t *testing.T) *client.MockChainClientRPC {
749751
mockRpc := client.NewMockChainClientRPC(t)

core/chains/evm/client/rpc_client.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ var (
117117
}, []string{"evmChainID", "nodeName", "rpcHost", "isSendOnly", "success", "rpcCallName"})
118118
)
119119

120+
const rpcSubscriptionMethodNewHeads = "newHeads"
121+
120122
// RPCClient includes all the necessary generalized RPC methods along with any additional chain-specific methods.
121123
//
122124
//go:generate mockery --quiet --name RPCClient --output ./mocks --case=underscore
@@ -215,7 +217,7 @@ func NewRPCClient(
215217

216218
func (r *RpcClient) SubscribeToHeads(ctx context.Context) (<-chan *evmtypes.Head, commontypes.Subscription, error) {
217219
channel := make(chan *evmtypes.Head)
218-
sub, err := r.subscribe(ctx, channel)
220+
sub, err := r.subscribe(ctx, channel, rpcSubscriptionMethodNewHeads)
219221
return channel, sub, err
220222
}
221223

tools/bin/go_core_race_tests_updated

-36
This file was deleted.

0 commit comments

Comments
 (0)