@@ -66,10 +66,9 @@ func (s *Suite) dialAs(key *ecdsa.PrivateKey) (*Conn, error) {
6666 return nil , err
6767 }
6868 conn .caps = []p2p.Cap {
69- {Name : "eth" , Version : 67 },
70- {Name : "eth" , Version : 68 },
69+ {Name : "eth" , Version : 69 },
7170 }
72- conn .ourHighestProtoVersion = 68
71+ conn .ourHighestProtoVersion = 69
7372 return & conn , nil
7473}
7574
@@ -156,7 +155,7 @@ func (c *Conn) ReadEth() (any, error) {
156155 var msg any
157156 switch int (code ) {
158157 case eth .StatusMsg :
159- msg = new (eth.StatusPacket )
158+ msg = new (eth.StatusPacket69 )
160159 case eth .GetBlockHeadersMsg :
161160 msg = new (eth.GetBlockHeadersPacket )
162161 case eth .BlockHeadersMsg :
@@ -229,9 +228,21 @@ func (c *Conn) ReadSnap() (any, error) {
229228 }
230229}
231230
231+ // dialAndPeer creates a peer connection and runs the handshake.
232+ func (s * Suite ) dialAndPeer (status * eth.StatusPacket69 ) (* Conn , error ) {
233+ c , err := s .dial ()
234+ if err != nil {
235+ return nil , err
236+ }
237+ if err = c .peer (s .chain , status ); err != nil {
238+ c .Close ()
239+ }
240+ return c , err
241+ }
242+
232243// peer performs both the protocol handshake and the status message
233244// exchange with the node in order to peer with it.
234- func (c * Conn ) peer (chain * Chain , status * eth.StatusPacket ) error {
245+ func (c * Conn ) peer (chain * Chain , status * eth.StatusPacket69 ) error {
235246 if err := c .handshake (); err != nil {
236247 return fmt .Errorf ("handshake failed: %v" , err )
237248 }
@@ -304,7 +315,7 @@ func (c *Conn) negotiateEthProtocol(caps []p2p.Cap) {
304315}
305316
306317// statusExchange performs a `Status` message exchange with the given node.
307- func (c * Conn ) statusExchange (chain * Chain , status * eth.StatusPacket ) error {
318+ func (c * Conn ) statusExchange (chain * Chain , status * eth.StatusPacket69 ) error {
308319loop:
309320 for {
310321 code , data , err := c .Read ()
@@ -313,12 +324,16 @@ loop:
313324 }
314325 switch code {
315326 case eth .StatusMsg + protoOffset (ethProto ):
316- msg := new (eth.StatusPacket )
327+ msg := new (eth.StatusPacket69 )
317328 if err := rlp .DecodeBytes (data , & msg ); err != nil {
318329 return fmt .Errorf ("error decoding status packet: %w" , err )
319330 }
320- if have , want := msg .Head , chain .blocks [chain .Len ()- 1 ].Hash (); have != want {
321- return fmt .Errorf ("wrong head block in status, want: %#x (block %d) have %#x" ,
331+ if have , want := msg .LatestBlock , chain .blocks [chain .Len ()- 1 ].NumberU64 (); have != want {
332+ return fmt .Errorf ("wrong head block in status, want: %d, have %d" ,
333+ want , have )
334+ }
335+ if have , want := msg .LatestBlockHash , chain .blocks [chain .Len ()- 1 ].Hash (); have != want {
336+ return fmt .Errorf ("wrong head block in status, want: %#x (block %d) have %#x" ,
322337 want , chain .blocks [chain .Len ()- 1 ].NumberU64 (), have )
323338 }
324339 if have , want := msg .ForkID , chain .ForkID (); ! reflect .DeepEqual (have , want ) {
@@ -348,13 +363,14 @@ loop:
348363 }
349364 if status == nil {
350365 // default status message
351- status = & eth.StatusPacket {
366+ status = & eth.StatusPacket69 {
352367 ProtocolVersion : uint32 (c .negotiatedProtoVersion ),
353368 NetworkID : chain .config .ChainID .Uint64 (),
354- TD : chain .TD (),
355- Head : chain .blocks [chain .Len ()- 1 ].Hash (),
356369 Genesis : chain .blocks [0 ].Hash (),
357370 ForkID : chain .ForkID (),
371+ EarliestBlock : 0 ,
372+ LatestBlock : chain .blocks [chain .Len ()- 1 ].NumberU64 (),
373+ LatestBlockHash : chain .blocks [chain .Len ()- 1 ].Hash (),
358374 }
359375 }
360376 if err := c .Write (ethProto , eth .StatusMsg , status ); err != nil {
0 commit comments