Skip to content

cmd/devp2p/internal/ethtest/conn.go — Version Comparison

v1.16.8 v1.17.3
Branch etc/v1.16.8-full-node etc/v1.17.3-full-node
Delta +14 -16 +18 -17
ETC delta on v1.16.8 (+14 -16)
diff --git a/cmd/devp2p/internal/ethtest/conn.go b/cmd/devp2p/internal/ethtest/conn.go
index 5182d71ce..d2d6673aa 100644
--- a/cmd/devp2p/internal/ethtest/conn.go
+++ b/cmd/devp2p/internal/ethtest/conn.go
@@ -66,9 +66,9 @@ func (s *Suite) dialAs(key *ecdsa.PrivateKey) (*Conn, error) {
        return nil, err
    }
    conn.caps = []p2p.Cap{
-       {Name: "eth", Version: 69},
+       {Name: "eth", Version: 68},
    }
-   conn.ourHighestProtoVersion = 69
+   conn.ourHighestProtoVersion = 68
    return &conn, nil
 }

@@ -155,7 +155,7 @@ func (c *Conn) ReadEth() (any, error) {
        var msg any
        switch int(code) {
        case eth.StatusMsg:
-           msg = new(eth.StatusPacket69)
+           msg = new(eth.StatusPacket68)
        case eth.GetBlockHeadersMsg:
            msg = new(eth.GetBlockHeadersPacket)
        case eth.BlockHeadersMsg:
@@ -229,7 +229,7 @@ func (c *Conn) ReadSnap() (any, error) {
 }

 // dialAndPeer creates a peer connection and runs the handshake.
-func (s *Suite) dialAndPeer(status *eth.StatusPacket69) (*Conn, error) {
+func (s *Suite) dialAndPeer(status *eth.StatusPacket68) (*Conn, error) {
    c, err := s.dial()
    if err != nil {
        return nil, err
@@ -242,7 +242,7 @@ func (s *Suite) dialAndPeer(status *eth.StatusPacket69) (*Conn, error) {

 // peer performs both the protocol handshake and the status message
 // exchange with the node in order to peer with it.
-func (c *Conn) peer(chain *Chain, status *eth.StatusPacket69) error {
+func (c *Conn) peer(chain *Chain, status *eth.StatusPacket68) error {
    if err := c.handshake(); err != nil {
        return fmt.Errorf("handshake failed: %v", err)
    }
@@ -315,7 +315,7 @@ func (c *Conn) negotiateEthProtocol(caps []p2p.Cap) {
 }

 // statusExchange performs a `Status` message exchange with the given node.
-func (c *Conn) statusExchange(chain *Chain, status *eth.StatusPacket69) error {
+func (c *Conn) statusExchange(chain *Chain, status *eth.StatusPacket68) error {
 loop:
    for {
        code, data, err := c.Read()
@@ -324,18 +324,17 @@ loop:
        }
        switch code {
        case eth.StatusMsg + protoOffset(ethProto):
-           msg := new(eth.StatusPacket69)
+           msg := new(eth.StatusPacket68)
            if err := rlp.DecodeBytes(data, &msg); err != nil {
                return fmt.Errorf("error decoding status packet: %w", err)
            }
-           if have, want := msg.LatestBlock, chain.blocks[chain.Len()-1].NumberU64(); have != want {
-               return fmt.Errorf("wrong head block in status, want: %d, have %d",
-                   want, have)
-           }
-           if have, want := msg.LatestBlockHash, chain.blocks[chain.Len()-1].Hash(); have != want {
+           if have, want := msg.Head, chain.blocks[chain.Len()-1].Hash(); have != want {
                return fmt.Errorf("wrong head block in status, want: %#x (block %d) have %#x",
                    want, chain.blocks[chain.Len()-1].NumberU64(), have)
            }
+           if have, want := msg.TD.Cmp(chain.TD()), 0; have != want {
+               return fmt.Errorf("wrong TD in status: have %v want %v", have, want)
+           }
            if have, want := msg.ForkID, chain.ForkID(); !reflect.DeepEqual(have, want) {
                return fmt.Errorf("wrong fork ID in status: have %v, want %v", have, want)
            }
@@ -363,14 +362,13 @@ loop:
    }
    if status == nil {
        // default status message
-       status = &eth.StatusPacket69{
+       status = &eth.StatusPacket68{
            ProtocolVersion: uint32(c.negotiatedProtoVersion),
            NetworkID:       chain.config.ChainID.Uint64(),
+           TD:              chain.TD(),
+           Head:            chain.blocks[chain.Len()-1].Hash(),
            Genesis:         chain.blocks[0].Hash(),
            ForkID:          chain.ForkID(),
-           EarliestBlock:   0,
-           LatestBlock:     chain.blocks[chain.Len()-1].NumberU64(),
-           LatestBlockHash: chain.blocks[chain.Len()-1].Hash(),
        }
    }
    if err := c.Write(ethProto, eth.StatusMsg, status); err != nil {
ETC delta on v1.17.3 (+18 -17)
diff --git a/cmd/devp2p/internal/ethtest/conn.go b/cmd/devp2p/internal/ethtest/conn.go
index 02579f8b5..f235dd5ca 100644
--- a/cmd/devp2p/internal/ethtest/conn.go
+++ b/cmd/devp2p/internal/ethtest/conn.go
@@ -66,10 +66,9 @@ func (s *Suite) dialAs(key *ecdsa.PrivateKey) (*Conn, error) {
        return nil, err
    }
    conn.caps = []p2p.Cap{
-       {Name: "eth", Version: 70},
-       {Name: "eth", Version: 69},
+       {Name: "eth", Version: 68},
    }
-   conn.ourHighestProtoVersion = 70
+   conn.ourHighestProtoVersion = 68
    return &conn, nil
 }

@@ -156,7 +155,7 @@ func (c *Conn) ReadEth() (any, error) {
        var msg any
        switch int(code) {
        case eth.StatusMsg:
-           msg = new(eth.StatusPacket)
+           msg = new(eth.StatusPacket68)
        case eth.GetBlockHeadersMsg:
            msg = new(eth.GetBlockHeadersPacket)
        case eth.BlockHeadersMsg:
@@ -165,6 +164,10 @@ func (c *Conn) ReadEth() (any, error) {
            msg = new(eth.GetBlockBodiesPacket)
        case eth.BlockBodiesMsg:
            msg = new(eth.BlockBodiesPacket)
+       case eth.NewBlockMsg:
+           msg = new(eth.NewBlockPacket)
+       case eth.NewBlockHashesMsg:
+           msg = new(eth.NewBlockHashesPacket)
        case eth.TransactionsMsg:
            msg = new(eth.TransactionsPacket)
        case eth.NewPooledTransactionHashesMsg:
@@ -226,7 +229,7 @@ func (c *Conn) ReadSnap() (any, error) {
 }

 // dialAndPeer creates a peer connection and runs the handshake.
-func (s *Suite) dialAndPeer(status *eth.StatusPacket) (*Conn, error) {
+func (s *Suite) dialAndPeer(status *eth.StatusPacket68) (*Conn, error) {
    c, err := s.dial()
    if err != nil {
        return nil, err
@@ -239,7 +242,7 @@ func (s *Suite) dialAndPeer(status *eth.StatusPacket) (*Conn, error) {

 // peer performs both the protocol handshake and the status message
 // exchange with the node in order to peer with it.
-func (c *Conn) peer(chain *Chain, status *eth.StatusPacket) error {
+func (c *Conn) peer(chain *Chain, status *eth.StatusPacket68) error {
    if err := c.handshake(); err != nil {
        return fmt.Errorf("handshake failed: %v", err)
    }
@@ -312,7 +315,7 @@ func (c *Conn) negotiateEthProtocol(caps []p2p.Cap) {
 }

 // statusExchange performs a `Status` message exchange with the given node.
-func (c *Conn) statusExchange(chain *Chain, status *eth.StatusPacket) error {
+func (c *Conn) statusExchange(chain *Chain, status *eth.StatusPacket68) error {
 loop:
    for {
        code, data, err := c.Read()
@@ -321,18 +324,17 @@ loop:
        }
        switch code {
        case eth.StatusMsg + protoOffset(ethProto):
-           msg := new(eth.StatusPacket)
+           msg := new(eth.StatusPacket68)
            if err := rlp.DecodeBytes(data, &msg); err != nil {
                return fmt.Errorf("error decoding status packet: %w", err)
            }
-           if have, want := msg.LatestBlock, chain.blocks[chain.Len()-1].NumberU64(); have != want {
-               return fmt.Errorf("wrong head block in status, want: %d, have %d",
-                   want, have)
-           }
-           if have, want := msg.LatestBlockHash, chain.blocks[chain.Len()-1].Hash(); have != want {
+           if have, want := msg.Head, chain.blocks[chain.Len()-1].Hash(); have != want {
                return fmt.Errorf("wrong head block in status, want: %#x (block %d) have %#x",
                    want, chain.blocks[chain.Len()-1].NumberU64(), have)
            }
+           if have, want := msg.TD.Cmp(chain.TD()), 0; have != want {
+               return fmt.Errorf("wrong TD in status: have %v want %v", have, want)
+           }
            if have, want := msg.ForkID, chain.ForkID(); !reflect.DeepEqual(have, want) {
                return fmt.Errorf("wrong fork ID in status: have %v, want %v", have, want)
            }
@@ -362,14 +364,13 @@ loop:
    }
    if status == nil {
        // default status message
-       status = &eth.StatusPacket{
+       status = &eth.StatusPacket68{
            ProtocolVersion: uint32(c.negotiatedProtoVersion),
            NetworkID:       chain.config.ChainID.Uint64(),
+           TD:              chain.TD(),
+           Head:            chain.blocks[chain.Len()-1].Hash(),
            Genesis:         chain.blocks[0].Hash(),
            ForkID:          chain.ForkID(),
-           EarliestBlock:   0,
-           LatestBlock:     chain.blocks[chain.Len()-1].NumberU64(),
-           LatestBlockHash: chain.blocks[chain.Len()-1].Hash(),
        }
    }
    if err := c.Write(ethProto, eth.StatusMsg, status); err != nil {

← Back to Version Comparison